Documentation ¶
Overview ¶
Package gouuidv6 implements "Version 6" UUIDs in Go. See http://bradleypeabody.github.io/uuidv6/ UUIDs sort correctly by time when naively sorted as raw bytes, have a Time() function that returns time the UUID was created and have a reasonable guarantee of being globally unique (based on the specifications from RFC 4122, with a few intentional exceptions.)
Index ¶
- func AlwaysRandomizeNode()
- func GetNode() uint64
- func RandomizeNode()
- func SetNode(nodeID uint64)
- type UUID
- func (u UUID) Bytes() []byte
- func (u UUID) Compare(to UUID) bool
- func (u UUID) HighBytes() []byte
- func (u UUID) IsNil() bool
- func (u UUID) LowBytes() []byte
- func (u UUID) MarshalBinary() ([]byte, error)
- func (u UUID) MarshalJSON() ([]byte, error)
- func (u UUID) MarshalText() ([]byte, error)
- func (u UUID) Node() uint64
- func (u *UUID) Scan(value interface{}) error
- func (u UUID) String() string
- func (u UUID) Time() time.Time
- func (u *UUID) UnmarshalBinary(data []byte) error
- func (u *UUID) UnmarshalJSON(data []byte) error
- func (u *UUID) UnmarshalText(text []byte) (err error)
- func (u UUID) Value() (driver.Value, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AlwaysRandomizeNode ¶
func AlwaysRandomizeNode()
AlwaysRandomizeNode sets the uuid generation in such way that each uuid has a random
func RandomizeNode ¶
func RandomizeNode()
RandomizeNode sets the 'node' part of the UUID to a random value, instead of using one of the MAC addresses from the system. Use this if you are concerned about the privacy aspect of using a MAC address.
Types ¶
type UUID ¶
type UUID [16]byte
UUID represents a "Version 6" UUID.
func New ¶
func New() UUID
New returns a new UUID initialized to a proper value according to "Version 6" rules.
func NewFromTime ¶
NewFromTime returns a new UUID set to the given time
func ParseBytes ¶
ParseBytes parses a slice of bytes into a UUID struct
func (UUID) MarshalBinary ¶
MarshalBinary returns a UUID as a slice of bytes
func (UUID) MarshalJSON ¶
MarshalJSON allows the UUID struct to be seamlessly used as a native json type
func (UUID) MarshalText ¶
MarshalText returns the String representation of a UUID as a slice of bytes
func (UUID) String ¶
String returns a textual representation per RFC 4122, e.g. "f81d4fae-7dec-11d0-a765-00a0c91e6bf6"
func (*UUID) UnmarshalBinary ¶
UnmarshalBinary updates a UUID struct using a slice of bytes representing a UUID
func (*UUID) UnmarshalJSON ¶
UnmarshalJSON allows the UUID struct to be seamlessly used as a native json type
func (*UUID) UnmarshalText ¶
UnmarshalText updates a UUID struct using a slice of bytes representing a UUID in string format