Documentation
¶
Overview ¶
Package ulid is part of the GoFastr harness.
See docs/harness-architecture.md for the architecture this package implements.
Package ulid implements a minimal pure-stdlib ULID generator.
ULIDs are 128-bit identifiers encoded as 26-character Crockford base32 strings. They are lexicographically sortable by creation time and URL-safe. The first 48 bits are the millisecond timestamp; the remaining 80 bits are random.
This implementation is intentionally minimal, it covers what the harness needs (generate, parse, validate) and nothing else. Spec: https://github.com/ulid/spec
Index ¶
Constants ¶
const Length = 26
Length is the number of characters in a ULID string.
Variables ¶
This section is empty.
Functions ¶
func MustNewPrefixed ¶
MustNewPrefixed returns a new prefixed ULID string and panics on error.
func NewPrefixed ¶
NewPrefixed returns a new prefixed ULID string like "sess_01H...". The prefix is lower-cased and joined with "_".
Types ¶
type ULID ¶
type ULID [16]byte
ULID is a 128-bit identifier.
func FromSeed ¶
FromSeed returns a deterministic ULID derived from the given 16-byte seed (typically a SHA-256 prefix). Used for branch ID rewriting where two clients branching the same boundary must produce the same new IDs.
func MustNew ¶
func MustNew() ULID
MustNew returns a new ULID and panics on error. Only the random source can fail; in practice this never happens.
func SplitPrefixed ¶
SplitPrefixed splits a prefixed ULID into (prefix, ulid). The ULID portion is validated. Returns an error on malformed input.
func (ULID) String ¶
String encodes the ULID as a 26-character Crockford base32 string.
The 128-bit value is encoded as 26 base32 characters (130 bits with the top 2 bits zero). The first character covers the top 3 bits of the timestamp; the remaining 25 characters cover 125 bits, totaling 128 bits + 2 leading zero bits.