package
0.305.0
Repository: https://github.com/adamluzsi/frameless.git
Documentation: pkg.go.dev

# README

UUID

V7

UUID v7 is monotonic within a process and ordered by time, making it ideal for databases and distributed systems.

id, err := uuid.MakeV7()
FieldBit PositionsByte PositionsLength (bits)Description
unix_ts_ms0–47uuid[0:6]4848-bit big-endian unsigned integer representing milliseconds since the Unix Epoch.
ver48–51uuid[6] (high nibble)44-bit version field, fixed to 0111 (7).
rand_a52–63uuid[6] (low nibble) – uuid[7]1212-bit field for additional time precision or monotonic counter within a millisecond.
var64–65uuid[8] (high 2 bits)22-bit variant field, fixed to 10 to conform with RFC 4122.
rand_b66–127uuid[8:16]6262-bit cryptographically secure random field (from crypto/rand).

V4

UUID v4 is completely random. It provides no ordering or time-based semantics — only uniqueness with extremely low collision probability (1 in 2^122).

id, err := uuid.MakeV4()
FieldBit PositionsByte PositionsLength (bits)Description
ver48–51uuid[6] (high nibble)44-bit version field, fixed to 0100 (4).
var64–65uuid[8] (high 2 bits)22-bit variant field, fixed to 10 to conform with RFC 4122.
randAll othersuuid[0:6], uuid[7:8], uuid[9:16]122122 cryptographically secure random bits (from crypto/rand).

Errors

When the Go runtime could not read random data from crypto/rand, it usually means:

  • You're running in a locked-down environment (like Docker or a VM) without /dev/urandom
  • The system is out of entropy (common on headless servers or cloud instances)
  • /dev/urandom is missing, unreadable, or blocked by a security policy
  • You're on an old or broken OS with no proper random number generator

The uuid package require cryptographically secure randomness. If crypto/rand fails, none of the UUID generation will be possible, unless you provide your own Random io.reader in the generators.