feat: Add support for UUID Version 8 (RFC 9562) #178
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
This adds support for generating UUID Version 8 as defined in RFC 9562. UUIDv8 is designed for custom or experimental use cases, allowing you to embed application-specific data while adhering to standard version and variant bits.
What’s included:
NewV8()
: Generates a UUIDv8 with random values.NewV8FromReader(customA, customB, r)
: Allows custom values forcustom_a
(48 bits) andcustom_b
(12 bits) whilecustom_c
field (62 bits) is filled using a random source or secure fallback.NewV8TimeBased(r)
: A time-based variant ofUUIDv8
that uses the current timestamp forcustom_a
. It also includes a sequence number to ensure uniqueness when multiple UUIDs are generated in the same nanosecond.This addition completes support for all UUID versions in RFC 9562. Looking forward for your feedback, team!