ulid

package
v0.17.2 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package ulid generates ULIDs (Universally Unique Lexicographically Sortable IDs) with zero external dependencies. A ULID is a 128-bit value: a 48-bit millisecond timestamp followed by 80 bits of randomness, encoded as 26 Crockford base32 characters. Lexical order matches creation order, which is exactly the "sortable by creation time" property nt relies on (SPEC §4).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() string

New returns a fresh ULID string. It is monotonic within a process: two ULIDs generated in the same millisecond still sort in generation order, so a burst of `nt add` calls (e.g. from an AI session) keep a stable order.

func Time added in v0.4.0

func Time(id string) (t time.Time, ok bool)

Time extracts the creation time from a ULID's 48-bit millisecond timestamp prefix (the first 10 characters). ok is false if id is too short or holds an invalid character. This is the inverse of the time bits New encodes, letting callers recover "when was this created" without storing a separate field.

Types

This section is empty.

Jump to

Keyboard shortcuts

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