types

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CantDecodeHex

func CantDecodeHex(err error, s string) error

CantDecodeHex wraps the given error with the given string that cannot be hex-decoded.

func CantParseFloat64

func CantParseFloat64(err error, s string) error

CantParseFloat64 wraps the given error with the specified string that cannot be parsed into float64.

func CantParseInt64

func CantParseInt64(err error, s string) error

CantParseInt64 wraps the given error with the specified string that cannot be parsed into int64.

func CantParseUint64

func CantParseUint64(err error, s string) error

CantParseUint64 wraps the given error with the specified string that cannot be parsed into uint64.

func CantPerformQuery

func CantPerformQuery(err error, q string) error

CantPerformQuery wraps the given error with the specified query that cannot be executed.

func CantUnmarshalYAML

func CantUnmarshalYAML(err error, v interface{}) error

CantUnmarshalYAML wraps the given error with the designated value, which cannot be unmarshalled into.

func Checksum

func Checksum(data interface{}) []byte

Checksum returns the SHA-1 checksum of the data.

func FromUnixMilli

func FromUnixMilli(ms int64) time.Time

FromUnixMilli creates and returns a time.Time value from the given milliseconds since the Unix epoch ms.

func MarshalJSON

func MarshalJSON(v interface{}) ([]byte, error)

MarshalJSON calls json.Marshal and wraps any resulting errors.

func MaxInt

func MaxInt[T constraints.Integer](x, y T) T

func Name

func Name(t interface{}) string

Name returns the declared name of type t.

func UnmarshalJSON

func UnmarshalJSON(data []byte, v interface{}) error

UnmarshalJSON calls json.Unmarshal and wraps any resulting errors.

Types

type Binary

type Binary []byte

Binary nullable byte string. Hex as JSON.

func (Binary) MarshalJSON

func (binary Binary) MarshalJSON() ([]byte, error)

MarshalJSON implements a custom marshal function to encode the Binary as a hex string. MarshalJSON implements the json.Marshaler interface. Supports JSON null.

func (Binary) MarshalText

func (binary Binary) MarshalText() ([]byte, error)

MarshalText implements a custom marhsal function to encode the Binary as hex. MarshalText implements the encoding.TextMarshaler interface.

func (*Binary) Scan

func (binary *Binary) Scan(src interface{}) error

Scan implements the sql.Scanner interface. Supports SQL NULL.

func (Binary) String

func (binary Binary) String() string

String returns the hex string representation form of the Binary.

func (*Binary) UnmarshalJSON

func (binary *Binary) UnmarshalJSON(data []byte) error

UnmarshalJSON implements a custom unmarshal function to decode a JSON hex string into a Binary. UnmarshalJSON implements the json.Unmarshaler interface. Supports JSON null.

func (*Binary) UnmarshalText

func (binary *Binary) UnmarshalText(text []byte) error

UnmarshalText implements a custom unmarshal function to decode hex into a Binary. UnmarshalText implements the encoding.TextUnmarshaler interface.

func (Binary) Valid

func (binary Binary) Valid() bool

Valid returns whether the Binary is valid.

func (Binary) Value

func (binary Binary) Value() (driver.Value, error)

Value implements the driver.Valuer interface. Supports SQL NULL.

type Bitmask

type Bitmask[T constraints.Integer] struct {
	// contains filtered or unexported fields
}

func (Bitmask[T]) Bits

func (b Bitmask[T]) Bits() T

func (*Bitmask[T]) Clear

func (b *Bitmask[T]) Clear(flag T)

func (Bitmask[T]) Has

func (b Bitmask[T]) Has(flag T) bool

func (*Bitmask[T]) Scan

func (b *Bitmask[T]) Scan(src interface{}) error

Scan implements the sql.Scanner interface.

func (*Bitmask[T]) Set

func (b *Bitmask[T]) Set(flag T)

func (*Bitmask[T]) Toggle

func (b *Bitmask[T]) Toggle(flag T)

func (Bitmask[T]) Value

func (b Bitmask[T]) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type Bool

type Bool struct {
	Bool  bool `db:"-"`
	Valid bool `db:"-"` // Valid is true if Bool is not NULL
}

Bool represents a bool for ENUM ('y', 'n'), which can be NULL.

func (Bool) MarshalJSON

func (b Bool) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (*Bool) Scan

func (b *Bool) Scan(src interface{}) error

Scan implements the sql.Scanner interface. Supports SQL NULL.

func (*Bool) UnmarshalJSON

func (b *Bool) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (*Bool) UnmarshalText

func (b *Bool) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (Bool) Value

func (b Bool) Value() (driver.Value, error)

Value implements the driver.Valuer interface. Supports SQL NULL.

type UnixMilli

type UnixMilli time.Time

UnixMilli is a nullable millisecond UNIX timestamp in databases and JSON.

func (UnixMilli) MarshalJSON

func (t UnixMilli) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface. Marshals to milliseconds. Supports JSON null.

func (*UnixMilli) Scan

func (t *UnixMilli) Scan(src interface{}) error

Scan implements the sql.Scanner interface. Scans from milliseconds. Supports SQL NULL.

func (UnixMilli) Time

func (t UnixMilli) Time() time.Time

Time returns the time.Time conversion of UnixMilli.

func (*UnixMilli) UnmarshalJSON

func (t *UnixMilli) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface. Unmarshals from milliseconds. Supports JSON null.

func (*UnixMilli) UnmarshalText

func (t *UnixMilli) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (UnixMilli) Value

func (t UnixMilli) Value() (driver.Value, error)

Value implements the driver.Valuer interface. Returns milliseconds. Supports SQL NULL.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL