idgen

package
v0.17.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 5, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package idgen produces ULID-format document IDs for Den.

IDs are 26-character Crockford base32 strings — 10 chars of 48-bit millisecond timestamp followed by 16 chars of 80-bit randomness — and are strictly monotonic within the same millisecond. The wire format matches the ULID spec at https://github.com/ulid/spec, so IDs are drop-in compatible with any external tooling that parses ULIDs.

Monotonicity matters because Den uses the document ID as the default sort key (Sort("_id"), cursor pagination via After/Before). Two inserts in the same millisecond with random tails would sort unpredictably, occasionally letting a fresh row land "before" a previous cursor.

The intra-millisecond step is a fresh 32-bit crypto/rand draw, not +1, so two consecutive IDs from the same millisecond don't reveal the next. Across millisecond boundaries the randomness is fully re-seeded.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() string

New returns a fresh ULID-format document ID. Safe for concurrent use.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL