Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Go
  3. xid

xid

MITGov1.2.1

A globally unique ID generator for the web, using a 12-byte Mongo Object ID algorithm with a compact base32hex string representation.

GitHubGitHub
4.3k stars212 forks0 contributors

What is xid?

xid is a globally unique ID generator library for Go, based on the Mongo Object ID algorithm. It produces compact, sortable 12-byte identifiers with a 20-character base32hex string representation, designed for web and server applications without requiring configuration or central coordination.

Target Audience

Go developers building distributed systems, web services, or databases who need efficient, sortable unique identifiers without setup overhead.

Value Proposition

Developers choose xid for its balance of small size, built-in sortability, and zero-configuration design, offering better performance and simplicity compared to UUIDs or Snowflake-like systems.

Overview

xid is a globally unique id generator thought for the web

Use Cases

Best For

  • Generating sortable primary keys in distributed databases
  • Adding request IDs to web server logs for tracing
  • Creating compact, URL-safe identifiers for API resources
  • Replacing UUIDs in Go applications where smaller, sortable IDs are beneficial
  • Embedding timestamps in IDs for chronological ordering without extra fields
  • Building stateless services that need unique IDs without central coordination

Not Ideal For

  • Applications requiring cryptographically secure, unpredictable IDs (e.g., security tokens or anti-fraud systems)
  • Systems needing sub-millisecond timestamp precision in IDs for fine-grained event ordering
  • High-throughput scenarios where a single host/process must generate over 16 million unique IDs per second

Pros & Cons

Pros

Compact and Efficient

At 12 bytes binary and 20 characters string, it's smaller than UUIDs (16 bytes, 36 chars), reducing storage and bandwidth overhead as highlighted in the comparison table.

Sortable and Time-Embedded

K-ordered with 1-second precision time embedding, enabling chronological sorting without extra database fields, based on the Mongo Object ID algorithm.

Zero Configuration

Works out-of-the-box without machine/data-center IDs or central servers, simplifying deployment in distributed systems as noted in the philosophy.

Lock-Free Performance

Avoids global locks used in UUIDv1/v2, ensuring better concurrency and speed, with benchmarks showing faster generation than UUIDs in multi-CPU environments.

URL-Safe Encoding

Uses base32hex for case-insensitive, sortable string representation that is web-friendly and avoids issues with non-alphanumeric characters in transports.

Cons

Not Cryptographically Secure

IDs are predictable due to reliance on system time and a monotonic counter, making it unsuitable for security-sensitive use cases, as admitted in the notes.

Coarse Time Precision

Limited to 1-second granularity, which may not suffice for applications requiring millisecond or microsecond accuracy in ID timestamps.

Unicity Per Second Limits

Guarantees only up to 16,777,216 unique IDs per second per host/process; high-scale systems could exhaust this, risking collisions under extreme load.

Go-Centric with Ports

Primarily a Go library, and while ports exist for other languages, they may lack the same maturity, documentation, or community support, limiting cross-platform adoption.

Frequently Asked Questions

Quick Stats

Stars4,277
Forks212
Contributors0
Open Issues16
Last commit3 months ago
CreatedSince 2015

Tags

#server-side#unique-id-generator#distributed-systems#go-library#database-ids

Built With

G
Go

Included in

Go169.1k
Auto-fetched 1 day ago

Related Projects

uuiduuid

Go package for UUIDs based on RFC 4122 and DCE 1.1: Authentication and Security Services.

Stars6,075
Forks422
Last commit1 year ago
ulidulid

Universally Unique Lexicographically Sortable Identifier (ULID) in Go

Stars5,035
Forks182
Last commit1 year ago
uuiduuid

A UUID package for Go

Stars1,807
Forks124
Last commit28 days ago
wuidwuid

An extremely fast globally unique number generator.

Stars546
Forks48
Last commit2 years ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub