ULID is a Go library that generates universally unique lexicographically sortable identifiers.
The library addresses limitations of traditional UUIDs and GUIDs by providing identifiers that combine a millisecond-precision timestamp with random data. ULIDs solve this by encoding 128 bits into a 26-character string using Crockford's base32, ensuring lexicographic sortability so IDs generated later sort after earlier ones. The approach handles monotonic ordering correctly even when multiple IDs are generated within the same millisecond, and the format is URL-safe with no special characters.
Developers should choose this library when building systems that benefit from sortable identifiers, such as databases where insertion order matters or distributed systems requiring natural ordering without additional indexes. The tool suits applications prioritizing compact representation and readability over the standardized UUID format. For simple use cases, the Make helper function provides sensible defaults with process-global pseudo-random entropy and automatic timestamp generation. Advanced users can construct ULIDs with custom timestamps and entropy sources, though this requires careful consideration of concurrency safety and security properties depending on the use case.
The project maintains a straightforward API with two primary construction paths: Make for convenience and New for control. The library includes both string and binary format support, reflecting a port of the JavaScript implementation with additional capabilities. Documentation emphasizes the flexibility of entropy source selection, with guidance on choosing between pseudo-random sources for general use, cryptographically secure entropy for security-sensitive applications, and performance optimization strategies like entropy pooling for high-throughput scenarios.