Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type UUID ¶
type UUID [16]byte
UUID is a 128 bit (16 byte) value defined by RFC9562.
var Nil UUID
Nil represents the zero-value UUID
func NewV4 ¶
NewV4 returns a Version 4 UUID as defined in RFC9562. Random bits are generated using crypto/rand.
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | random_a | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | random_a | ver | random_b | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |var| random_c | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | random_c | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
func NewV7 ¶
NewV7 returns a Version 7 UUID as defined in RFC9562. Random bits are generated using crypto/rand.
This function employs method 3 (Replace Leftmost Random Bits with Increased Clock Precision) to increase the clock precision of the UUID. This helps support scenarios where several UUIDs are generated within the same millisecond.
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | unix_ts_ms | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | unix_ts_ms | ver | rand_a | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |var| rand_b | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | rand_b | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
func Parse ¶
Parse a UUID string with or without the dashes.
u, err := Parse("56c450b3255d4a2aa761cd1b1bf028e2") // no dashes u, err := Parse("56c450b3-255d-4a2a-a761-cd1b1bf028e2") // with dashes u, err := Parse("urn:uuid:56c450b3-255d-4a2a-a761-cd1b1bf028e2") // urn uuid prefix
func (UUID) MarshalText ¶ added in v1.0.1
func (UUID) String ¶
String returns the UUID in "hex-and-dash" string format.
56c450b3-255d-4a2a-a761-cd1b1bf028e2
func (UUID) URN ¶
URN returns the UUID in "urn:uuid" string format.
urn:uuid:56c450b3-255d-4a2a-a761-cd1b1bf028e2