uuid

A pure Go implementation of RFC-9562 UUIDs, covering generation and parsing for versions 1 and 3 through 8.

Library
Go
vv4.4.0+incompatible
1,808stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
73/100Good
Development Activity64
Maintenance64
Community64
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
82/100Excellent
Architecture85
Code Quality92
Innovation62
Learning Curve90

gofrs/uuid provides a dependency-free Go implementation of Universally Unique Identifiers as specified in RFC-9562 (the successor to RFC-4122). It supports the full range of UUID versions still in active use: time-and-MAC-based V1, name-based V3 (MD5) and V5 (SHA-1), random V4, the k-sortable V6 and V7 timestamp-based variants, and the custom-layout V8. The package originated as a fork of satori/go.uuid after that project stalled with known bugs, and the gofrs organization has maintained it as the community’s de facto standard UUID library since.

Beyond generation, the package handles parsing of every common textual UUID form (canonical dashed, braced, URN-prefixed, and bare hex), plus binary and text (un)marshaling, database/sql Valuer/Scanner implementations (including a NullUUID type for nullable columns), and JSON marshaling. A pluggable Generator interface and GenOption functions let callers swap in a custom random source, MAC-address function, or clock, which matters for anyone who needs deterministic or MAC-obfuscated UUIDs in tests or privacy-sensitive contexts.

What You Get

  • Generators for UUID versions 1, 3, 4, 5, 6, 7, and 8, each exposed as both a package-level convenience function and a method on a swappable Generator interface
  • A monotonic, batching-aware V7 generator that guarantees strictly increasing UUIDs from a single generator instance even within the same millisecond or across a backwards clock jump
  • Parsing for canonical, braced, URN-prefixed, and bare-hex textual UUID formats via Parse, FromString, and the encoding.TextUnmarshaler interface
  • First-class database/sql integration through driver.Valuer and sql.Scanner on UUID, plus a NullUUID wrapper type for nullable database columns
  • JSON support via MarshalJSON/UnmarshalJSON on NullUUID and the standard text marshaler on UUID, so UUIDs serialize cleanly in API payloads
  • Configurable generation through GenOption functions (WithRandomReader, WithEpochFunc, WithHWAddrFunc) for deterministic testing or MAC-address obfuscation

Common Use Cases

  • Generating primary keys or external-facing identifiers for database rows using V4 (random) or V7 (time-sortable) UUIDs
  • Producing deterministic, content-derived identifiers with V5 name-based hashing against a fixed namespace
  • Storing and retrieving UUID columns directly as Go values through the database/sql driver interfaces, including nullable columns via NullUUID
  • Building k-sortable identifiers for time-ordered data (event logs, message queues) with V6 or V7, where insertion order should match ID order
  • Parsing and validating UUIDs received from external systems in any of the RFC-9562-accepted text encodings

Under The Hood

Architecture The package is a flat, single-package library split by responsibility across five files rather than layered directories: uuid.go defines the UUID array type, byte layout, and versioned constants; generator.go holds the Gen struct and all NewV* constructors; codec.go handles text/binary parsing and marshaling; sql.go covers database/sql and JSON integration; error.go defines typed sentinel errors. Generation flows through package-level functions like NewV4()/NewV7(), which delegate to a DefaultGenerator built by NewGen(), while callers needing custom randomness, clock, or MAC sources construct their own Gen via NewGenWithOptions — a clean dependency-injection seam that isolates the one genuinely stateful part of the library (the mutex-protected clock sequence and V7 counter in Gen) from the otherwise-pure encode/decode logic elsewhere. The core UUID type has no abstraction layer between it and its byte-level encoding, so every generator and codec function would need to change in lockstep if that layout changed — acceptable rigidity for a value type meant to behave like a fixed-size array.

Tech Stack The module is pure standard library, declaring zero third-party dependencies in go.mod. It draws on crypto/rand for secure randomness in V4/V6/V7 generation, crypto/md5 and crypto/sha1 for V3/V5 name-based hashing, database/sql and database/sql/driver for the Value/Scan integration, encoding/binary for timestamp bit-packing in V1/V6/V7, net for MAC address discovery, and sync (Once, Mutex) to guard one-time initialization and shared counter state. There is no build tooling beyond the standard Go toolchain; CI runs a dedicated Go workflow alongside CodeQL and OpenSSF Scorecard analysis, with Dependabot watching for supply-chain issues.

Code Quality Testing is extensive and table-driven, spanning six test files with dozens of top-level Test functions covering deterministic fixtures for every UUID version, malformed-input parsing cases, and round-trip Scan/Value/MarshalJSON behavior; a pre-commit configuration and multiple CI workflows enforce this on every push. Error handling is explicit and typed throughout, using a custom Error string type that implements the error interface for stable sentinel matching, wrapped with fmt.Errorf’s %w verb so callers can use errors.Is against a shared underlying error. Naming is idiomatic Go, and the code favors named constants over magic numbers, with inline RFC diagrams documenting the trickier bit-packing logic.

What Makes It Unique The library doesn’t invent new UUID semantics — RFC-9562 defines the versions — but its V7 implementation goes beyond the specification’s minimum bar by adding a monotonic counter that guarantees strictly increasing UUIDs from a single generator even when multiple UUIDs are requested within the same millisecond or the system clock moves backwards, a correctness property many other language implementations skip. Its practical edge over generic UUID packages is breadth combined with polish: a single dependency-free package spans every active UUID version, including the rarely-implemented custom V8, with drop-in database/sql and JSON integration baked in.

Used by 9 apps in this directory

Go
83%
AGPL 3.0

Beta9

Developer Tools · AI Development · Data Engineering

1,777

Run AI workloads at scale with a Pythonic serverless runtime that handles GPU inference, background jobs, and sandboxes with zero infrastructure overhead.

View details
85
Repo Health
78
Technical
66
Dependency
Built with
Go83%
Python16%
Updated 2 days ago
Go
91%
AGPL 3.0

Cozy Stack

File Storage · Productivity

1,269

Self-hosted personal cloud platform that unifies your files, apps, and devices in one private space you fully control.

View details
95
Repo Health
77
Technical
67
Dependency
Built with
Go91%
Updated 3 days ago
Go
65%
Other

Hanko

Security · Authentication

9,025

Open source, self-hostable authentication platform with passkeys, SAML SSO, and OAuth — the privacy-first alternative to Auth0 and Clerk.

View details
89
Repo Health
81
Technical
66
Dependency
Built with
Go65%
TypeScript30%
Updated 4 days ago
Go
42%
AGPL 3.0

listmonk

Marketing · Blogging

23,418

High-performance, self-hosted newsletter and mailing list manager packaged as a single binary with built-in analytics, transactional messaging, and multi-channel delivery.

View details
87
Repo Health
74
Technical
67
Dependency
Built with
Go42%
Vue24%
JavaScript19%
Updated 4 days ago
Go
95%
Apache 2.0

Nakama

Developer Tools · Game Development

13,330

Open-source game backend server with built-in multiplayer, matchmaking, leaderboards, chat, authentication, and storage — deploy anywhere via Docker or binary.

View details
91
Repo Health
73
Technical
73
Dependency
Built with
Go95%
Updated 6 days ago
Go
91%
Apache 2.0

Ory Kratos

Authentication

13,877

API-first identity and user management that handles login, registration, MFA, and recovery so your application never has to.

View details
82
Repo Health
78
Technical
65
Dependency
Built with
Go91%
Updated 1 months ago
Python
54%
Other

PostHog

Analytics · Monitoring · Developer Tools

39,797

The all-in-one open source product platform combining analytics, session replay, feature flags, error tracking, AI observability, and a built-in data warehouse in a single self-hostable stack.

View details
92
Repo Health
80
Technical
65
Dependency
Built with
Python54%
TypeScript36%
Updated 2 days ago
Go
98%
Other

Tyk API Gateway

Developer Tools · Devops

10,823

Cloud-native, high-performance open-source API gateway for REST, GraphQL, gRPC, and TCP — built in Go since 2014 with no feature lockout.

View details
97
Repo Health
78
Technical
66
Dependency
Built with
Go98%
Updated 3 days ago
Go
78%
MIT

Wakapi

Developer Tools · Analytics

4,432

Self-hosted WakaTime-compatible coding statistics backend that gives developers full control over their coding activity data.

View details
90
Repo Health
77
Technical
72
Dependency
Built with
Go78%
HTML12%
Updated 3 days 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