Documentation ¶
Overview ¶
Package luid implements IDs that are (practically always) sequential but are not iterative like auto incrementing IDs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ID ¶
type ID [12]byte
ID is an array of 12 bytes that is composed of 8 bytes of time and 4 random bytes in big endian byte order.
func FromString ¶
FromString unmarshals hex and returns an ID.
hex can be any valid hexadecimal number of len(ID) bytes. FromString does not check whether hex corrosponds to a valid ID.
func New ¶
New returns a new ID and the time.Time (current time in UTC) used for the first 8 bytes of ID.
Remember to call rand.Seed before using New.
func (ID) MarshalText ¶
MarshalText implements encoding.TextMarshaler interface. And returns the hexadecimal encoding of ID.
func (*ID) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler interface. text is supposed to be the hexadecimal encoding of an ID.
type NullID ¶
NullID represents an ID that may be null. It is identical to sql.NullString.
func (NullID) MarshalJSON ¶
MarshalJSON implements json.Marshalar interface.
func (*NullID) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshalar interface.