Documentation ¶
Overview ¶
Package uid ...
UUID V7 uses Method 3 (Replace Leftmost Random Bits with Increased Clock Precision) to implement single-node monotonicity.
Index ¶
- Constants
- func Compare(a, b UUID) int
- type ParseError
- type UUID
- func (u UUID) Bytes() []byte
- func (u UUID) Compact32() string
- func (u UUID) Compact64() string
- func (u UUID) IsMax() bool
- func (u UUID) IsNil() bool
- func (u UUID) MarshalBinary() ([]byte, error)
- func (u UUID) MarshalJSON() ([]byte, error)
- func (u UUID) MarshalText() ([]byte, error)
- func (u UUID) String() string
- func (u UUID) Time() time.Time
- func (u *UUID) UnmarshalBinary(b []byte) error
- func (u *UUID) UnmarshalJSON(b []byte) error
- func (u *UUID) UnmarshalText(b []byte) error
- func (u UUID) Variant() Variant
- func (u UUID) Version() Version
- type Variant
- type Version
Constants ¶
const ( // MaxCanonical is the canonical RFC9562 "Max" UUID. MaxCanonical = "ffffffff-ffff-ffff-ffff-ffffffffffff" // MaxCompact32 is the canonical NCName Compact Base32 "Max" UUID. MaxCompact32 = "P777777777777777777777777P" // MaxCompact64 is the canonical NCName Compact Base64 "Max" UUID. MaxCompact64 = "P____________________P" // NilCanonical is the canonical RFC9562 "Nil" UUID. NilCanonical = "00000000-0000-0000-0000-000000000000" // NilCompact32 is the canonical NCName Compact Base32 "Nil" UUID. NilCompact32 = "AAAAAAAAAAAAAAAAAAAAAAAAAA" // NilCompact64 is the canonical NCName Compact Base64 "Nil" UUID. NilCompact64 = "AAAAAAAAAAAAAAAAAAAAAA" )
const ( // VersionNil is the Nil UUID version. VersionNil = Version(0b0000_0000) // Version4 is the version of random UUIDs. Version4 = Version(0b0000_0100) // Version7 is the version of time-sortable UUIDs. Version7 = Version(0b0000_0111) // VersionMax is the Max UUID version. VersionMax = Version(0b0000_1111) )
const ( // Variant9562 is the value of the variant bits of v4 or v7. Variant9562 = Variant(0b0000_0010) // VariantNil is the value of the variant bits of a Nil UUID. VariantNil = Variant(0b0000_0000) // VariantMax is the value of the variant bits of a Max UUID. VariantMax = Variant(0b0000_0111) )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type UUID ¶
type UUID struct {
// contains filtered or unexported fields
}
UUID is a UUID as defined by RFC... Underlying array is unexported for immutability. UUID is comparable using `==`. The zero value is Nil UUID.
func NewV7Strict ¶
func NewV7Strict() UUID
NewV7Strict returns a v7 UUID with guaranteed (beyond RFC method 3) local monotonicity. You don't need this, if you think you need finer than sub-millisecond precision in IDs, what you really need is a sequence generator and not more accurate timekeeping.
func Parse ¶
Parse attempts to parse `src` into a UUID and returns the parsed UUID and `true` on success. On failure, Parse returns the Nil UUID and `false`.
func (UUID) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler. Never returns errors.
func (UUID) MarshalJSON ¶
MarshalJSON implements encoding/json.Marshaler. Never returns errors.
func (UUID) MarshalText ¶
MarshalText implements encoding.TextMarshaler. Never returns errors.
func (UUID) Time ¶
Time returns the embedded timestamp of UUID. For non-V7 zero(time.Time) is returned. If you don't pre-check version use `.IsZero()` to ensure time is "real".
func (*UUID) UnmarshalBinary ¶
UnmarshalBinary implement encoding.BinaryUnmarshaler.
func (*UUID) UnmarshalJSON ¶
UnmarshalJSON implements encoding/json.Unmarshaler.
func (*UUID) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.