Documentation ¶
Index ¶
- Constants
- func MarshalID(id ID) graphql.Marshaler
- type ID
- func (id ID) MarshalBinary() ([]byte, error)
- func (id ID) MarshalBinaryTo(dst []byte) error
- func (id ID) MarshalText() ([]byte, error)
- func (id *ID) Scan(src interface{}) error
- func (id ID) String() string
- func (id *ID) UnmarshalBinary(data []byte) error
- func (id *ID) UnmarshalText(v []byte) error
- func (id ID) Value() (driver.Value, error)
Constants ¶
const EncodedSize = ulid.EncodedSize + 2
EncodedSize is the length of a text encoded PULID.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ID ¶
ID - Prefixed ULID. The first two characters indicate the type of entity being described.
func (ID) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface by returning the ULID as a byte slice.
func (ID) MarshalBinaryTo ¶
MarshalBinaryTo writes the binary encoding of the ULID to the given buffer. ErrBufferSize is returned when the len(dst) != 16.
func (ID) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface by returning the string encoded ULID.
func (*ID) Scan ¶
Scan implements the sql.Scanner interface. It supports scanning a string or byte slice.
func (*ID) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface by copying the passed data and converting it to an ULID. ErrDataSize is returned if the data length is different from ULID length.
func (*ID) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface by
func (ID) Value ¶
Value implements the sql/driver.Valuer interface. This returns the value represented as a byte slice. If instead a string is desirable, a wrapper type can be created that calls String().
// stringValuer wraps a ULID as a string-based driver.Valuer. type stringValuer ULID func (id stringValuer) Value() (driver.Value, error) { return ULID(id).String(), nil } // Example usage. db.Exec("...", stringValuer(id))