Documentation ¶
Index ¶
- type ID
- func (id ID) Bytes() []byte
- func (id ID) Entropy() []byte
- func (id ID) IsZero() bool
- func (id ID) MarshalBinary() ([]byte, error)
- func (id ID) MarshalText() ([]byte, error)
- func (id *ID) MustSetTime(t time.Time)
- func (id *ID) SetEntropy(entropy []byte)
- func (id *ID) SetTime(t time.Time) error
- func (id ID) String() string
- func (id ID) Time() time.Time
- func (id *ID) UnmarshalBinary(data []byte) error
- func (id *ID) UnmarshalText(data []byte) error
- func (id ID) WithEntropy(entropy []byte) ID
- func (id ID) WithTime(t time.Time) ID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ID ¶
type ID [16]byte
ID is 128-bit sortable unique ID.
See specification at https://github.com/ulid/spec
func (ID) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (ID) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface.
func (*ID) MustSetTime ¶
MustSetTime is a convenience function equivalent to SetTime that panics on failure instead of returning an error.
func (*ID) SetEntropy ¶
SetEntropy sets an ID's entropy. Excess entropy is truncated to the first 10 bytes. Insufficient entropy will be padded to 10 bytes with leading zeroes.
func (*ID) SetTime ¶
SetTime sets an ID's time component.
If time is known to be between the years [1970, 10889), the error may be safely ignored; see MustSetTime.
func (*ID) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
func (*ID) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface.
func (ID) WithEntropy ¶
WithEntropy is a convenience function equivalent to SetEntropy which returns a copy of an ID with the given entropy.