Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #241 +/- ##
==========================================
Coverage ? 100.00%
==========================================
Files ? 5
Lines ? 461
Branches ? 0
==========================================
Hits ? 461
Misses ? 0
Partials ? 0 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds UUIDv8 support (RFC 9562) to the library, enabling callers to construct version 8 UUIDs from custom user-provided fields.
Changes:
- Introduces the
V8UUID version constant and documents v8 as supported. - Adds
NewV8at both package level and generator level, including validation and a new sentinel error (ErrV8FieldLength). - Adds generator tests covering UUIDv8 creation, field placement, version/variant bits, and invalid input lengths.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| uuid.go | Exposes V8 as an official UUID version constant. |
| generator.go | Adds UUIDv8 generation API and implementation, plus a new method on the Generator interface. |
| error.go | Adds ErrV8FieldLength sentinel error for invalid UUIDv8 field lengths. |
| generator_test.go | Adds test coverage for UUIDv8 creation, bit layout, and validation errors. |
| README.md | Lists Version 8 as a supported UUID version. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -109,6 +122,7 @@ type Generator interface { | |||
| NewV6AtTime(time.Time) (UUID, error) | |||
| NewV7() (UUID, error) | |||
| NewV7AtTime(time.Time) (UUID, error) | |||
There was a problem hiding this comment.
Adding NewV8 to the exported Generator interface is a breaking API change for any downstream code that implements uuid.Generator (their types will no longer satisfy the interface after upgrading). Consider avoiding widening this interface (e.g., introduce a separate interface for V8 support, or keep Generator stable and expose NewV8 only on *Gen / via a narrower optional interface assertion).
| NewV7AtTime(time.Time) (UUID, error) | |
| NewV7AtTime(time.Time) (UUID, error) | |
| } | |
| // V8Generator extends Generator with support for generating version 8 UUIDs. | |
| // Implementations that support V8 can optionally satisfy this interface. | |
| type V8Generator interface { | |
| Generator |
| // UUID versions. | ||
| const ( | ||
| _ byte = iota | ||
| V1 // Version 1 (date-time and MAC address) | ||
| _ // Version 2 (date-time and MAC address, DCE security version) [removed] | ||
| V3 // Version 3 (namespace name-based) | ||
| V4 // Version 4 (random) | ||
| V5 // Version 5 (namespace name-based) | ||
| V6 // Version 6 (k-sortable timestamp and random data, field-compatible with v1) | ||
| V7 // Version 7 (k-sortable timestamp and random data) | ||
| _ // Version 8 (k-sortable timestamp, meant for custom implementations) [not implemented] | ||
| V8 // Version 8 (custom UUID implementations) | ||
| ) |
There was a problem hiding this comment.
Now that V8 is a supported UUID version, the package-level documentation still states RFC-9562 specifies versions 1, 3, 4, 5, 6 and 7. Please update the doc comment near the top of uuid.go to include version 8 so the documentation stays accurate.
| * Version 5, based on SHA-1 hashing of a named value | ||
| * Version 6, a k-sortable id based on timestamp, and field-compatible with v1 | ||
| * Version 7, a k-sortable id based on timestamp | ||
| * Version 8, for custom uuid implementations |
There was a problem hiding this comment.
README bullet uses "custom uuid implementations" while the rest of the document uses "UUID". Consider capitalizing "UUID" here for consistency and readability.
| * Version 8, for custom uuid implementations | |
| * Version 8, for custom UUID implementations |
No description provided.