ulid

A Go library for generating and parsing ULIDs — universally unique, lexicographically sortable identifiers.

Library
Go
vv2.1.2
5,051stars
Apache License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
53/100Fair
Development Activity36
Maintenance24
Community52
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
84/100Excellent
Architecture78
Code Quality92
Innovation85
Learning Curve80

oklog/ulid is a Go implementation of the ULID specification, providing Universally Unique Lexicographically Sortable Identifiers as a drop-in alternative to UUIDs. Each ULID packs a 48-bit millisecond timestamp and 80 bits of entropy into a fixed 16-byte array, encoded as a 26-character Crockford Base32 string that sorts the same lexicographically as it does chronologically.

The package exposes low-allocation constructors (ulid.New, ulid.Make), parsing (Parse, ParseStrict), and monotonic entropy sources that guarantee strictly increasing IDs generated within the same millisecond. It implements the standard encoding.TextMarshaler, encoding.BinaryMarshaler, and database/sql/driver.Valuer/Scanner interfaces, so ULIDs slot directly into JSON APIs, binary protocols, and SQL columns without custom glue code. A companion CLI (cmd/ulid) generates and parses ULIDs from the command line.

What You Get

  • A ULID type backed by a [16]byte array with zero-allocation binary encoding
  • Millisecond-precision, monotonically increasing ID generation via ulid.Make and ulid.Monotonic
  • Strict and lenient parsers (Parse, ParseStrict) for round-tripping the 26-character Base32 string form
  • Native support for database/sql, encoding/json, and binary marshaling interfaces
  • A standalone ulid command-line tool for generating and inspecting IDs outside of Go code

Common Use Cases

  • Primary keys for database rows that need to sort by creation time without a separate timestamp column
  • Distributed request/trace IDs where lexicographic sort order doubles as chronological order
  • Replacing UUID v4 primary keys in high-write systems to reduce B-tree index fragmentation
  • Generating collision-resistant, URL-safe identifiers for object storage keys and event logs

Under The Hood

Architecture A single flat package (ulid.go, ~720 lines) is built around a [16]byte-backed ULID type with no internal layering — timestamp (bytes 0-5) and entropy (bytes 6-15) are packed directly into the array and manipulated with bit-shifting rather than through an internal struct, and the separate cmd/ulid binary is the only consumer split out from the core package, wiring the library’s New/Parse/Monotonic API to a pborman/getopt CLI. Monotonicity is handled by a MonotonicEntropy/LockedMonotonicReader pair that wraps an io.Reader in a bufio.Reader and tracks a package-level uint80 counter, so the only meaningful layer boundary in the codebase is between the pure data type (encoding/parsing/comparison methods on ULID) and the stateful entropy sources that feed it; changing the core byte layout would ripple through every marshal/unmarshal method since offsets are hardcoded by index rather than derived from named constants.

Tech Stack The core package uses only the standard library — encoding/binary, math/bits, crypto/rand and math/rand, database/sql/driver, and sync cover parsing, monotonic increments, and SQL integration — with zero third-party runtime dependencies declared in go.mod (module github.com/oklog/ulid/v2, go 1.15). The sole external dependency, github.com/pborman/getopt/v2, is scoped to the optional cmd/ulid CLI binary, not the importable package. Build and test tooling is plain go build/go test, with CI running gofmt, go vet, staticcheck, and go test -race across Linux, macOS, and Windows on the current Go toolchain.

Code Quality A single, extensive test file uses property-based checks (testing/quick) for randomized round-trip verification alongside explicit doctest-style examples and error-path assertions, giving dense coverage of the small public surface. Error handling is idiomatic Go with typed sentinel errors rather than panics in the non-Must* API, comments are precise and credit upstream sources for optimized routines, and CI enforces formatting, vet, and static-analysis checks on every push in addition to running the race detector across three operating systems — a level of quality-gate rigor above most Go libraries of comparable scope.

API Design The public API is deliberately layered from convenience to control: ulid.Make() takes zero arguments for the common case, ulid.New(ms, entropy) exposes the two dimensions that matter, and Monotonic/LockedMonotonicReader let advanced users opt into strict ordering guarantees without changing call sites elsewhere. The type implements every standard Go serialization interface a caller could want (TextMarshaler, BinaryMarshaler, sql.Scanner/driver.Valuer) so a ULID field works directly in JSON, raw byte protocols, and any database/sql driver without adapter code, and the doc comments even demonstrate how to wrap the type for edge cases the maintainers deliberately didn’t special-case — a level of documented extensibility that’s more thoughtful than most ID-generation libraries offer.

Used by 8 apps in this directory

Go
73%
Other

Convoy

Developer Tools · Devops

2,862

Convoy is an open-source, cloud-native webhooks gateway that ingests events over HTTP or straight from Kafka, SQS, Google Pub/Sub, and RabbitMQ, then reliably delivers them to subscriber endpoints with signed payloads, automatic retries, circuit breaking, and JavaScript-based transformations.

View details
89
Repo Health
81
Technical
66
Dependency
Built with
Go73%
TypeScript13%
HTML12%
Updated yesterday
TypeScript
49%
AGPL 3.0

Grafana

Monitoring · Analytics

76,498

The open-source observability platform that unifies metrics, logs, and traces from any data source into dynamic, queryable dashboards.

View details
95
Repo Health
91
Technical
65
Dependency
Built with
TypeScript49%
Go45%
Updated today
Go
56%
Other

Multica

AI Assistants · AI Development

48,263

Turn coding agents into real teammates — assign issues, track progress, and compound reusable skills across a vendor-neutral, self-hosted platform.

View details
86
Repo Health
83
Technical
70
Dependency
Built with
Go56%
TypeScript39%
Updated today
Go
78%
Apache 2.0

OpenMeter

Invoicing Finance · Developer Tools

2,236

Open-source metering and billing engine for AI, agentic, and DevTool monetization — ingest usage events in real time and turn them into accurate invoices automatically.

View details
86
Repo Health
81
Technical
66
Dependency
Built with
Go78%
TypeScript17%
Updated 2 days ago
Go
90%
AGPL 3.0

Pyroscope

Monitoring · Devops · Developer Tools

11,643

An open-source, horizontally scalable continuous profiling platform that pinpoints CPU, memory, and I/O bottlenecks down to the exact line of code, built by Grafana Labs alongside Loki, Tempo, and Mimir.

View details
91
Repo Health
89
Technical
66
Dependency
Built with
Go90%
Updated 2 days ago
Go
71%
MIT

sandboxd

Developer Tools · Devops

923

Self-hosted engine for AI app-builder products: give every user an isolated sandbox, a built-in coding agent, and a live preview URL — one command, no Kubernetes.

View details
74
Repo Health
83
Technical
68
Dependency
Built with
Go71%
TypeScript23%
Updated 2 days ago
TypeScript
52%
Other

SigNoz

Monitoring · Analytics

31,972

Self-host your entire observability stack — logs, metrics, traces, and LLM monitoring — in one OpenTelemetry-native platform, without the Datadog bill.

View details
92
Repo Health
83
Technical
69
Dependency
Built with
TypeScript52%
Go37%
Updated today
Go
54%
AGPL 3.0

Uptrace

Monitoring · Devops

4,274

Unified open-source APM that collects OpenTelemetry traces, metrics, and logs into a single self-hosted platform backed by ClickHouse.

View details
63
Repo Health
70
Technical
66
Dependency
Built with
Go54%
Vue34%
Updated 2 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search