Skip to content

docs: clarify Invalid Variant documentation and usage - #231

Open
AdamMagued wants to merge 1 commit into
google:masterfrom
AdamMagued:clarify-invalid-variant
Open

AdamMagued wants to merge 1 commit into
google:masterfrom
AdamMagued:clarify-invalid-variant

Conversation

@AdamMagued

Copy link
Copy Markdown

Summary

Any valid 128-bit UUID classifies into RFC4122, Reserved, Microsoft, or Future. Because all 256 byte patterns for byte 8 fall into one of those four branches, (UUID).Variant() never returns Invalid for a 16-byte UUID; Invalid represents an uninitialized or non-UUID sentinel.

Changes

  • Clarified documentation on Variant, the Variant constants block, and (UUID).Variant() to explain variant classification and the role of Invalid.
  • Added an explanatory comment to uuid_test.go table entries where Parse returns an error.
  • Added explicit unit tests verifying Variant.String() returns "Invalid" for Variant(0) and Invalid, and that all byte values in byte 8 classify into valid variants.

Fixes #91

Any valid 128-bit UUID classifies into RFC4122, Reserved, Microsoft, or
Future. Variant never returns Invalid on a 16-byte UUID; Invalid represents
an uninitialized or non-UUID sentinel.

Update documentation for Variant, the variant constants, and (UUID).Variant
to make this explicit. Additionally, document the invalid cases in unit test
tables where parsing returns an error, and add an explicit test verifying
Variant.String() returns "Invalid" for Variant(0) / Invalid.

Fixes google#91
@AdamMagued
AdamMagued requested a review from a team as a code owner October 2, 2026 21:49
@google-cla

google-cla Bot commented Oct 2, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

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.

Update documentation and code for Invalid Variant

1 participant