Skip to content

Feature/uuidv8#241

Draft
cameracker wants to merge 3 commits intomasterfrom
feature/uuidv8
Draft

Feature/uuidv8#241
cameracker wants to merge 3 commits intomasterfrom
feature/uuidv8

Conversation

@cameracker
Copy link
Collaborator

No description provided.

@codecov
Copy link

codecov bot commented Mar 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (master@7103330). Learn more about missing BASE report.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 V8 UUID version constant and documents v8 as supported.
  • Adds NewV8 at 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)
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
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

Copilot uses AI. Check for mistakes.
Comment on lines 53 to 64
// 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)
)
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
* 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
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

README bullet uses "custom uuid implementations" while the rest of the document uses "UUID". Consider capitalizing "UUID" here for consistency and readability.

Suggested change
* Version 8, for custom uuid implementations
* Version 8, for custom UUID implementations

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants