Stdlib UUID (go1.27) - #77
Merged
Merged
Conversation
Go 1.27 introduces a stdlib uuid package. Its uuid.UUID resolves to
{type: string, format: uuid} by type identity — import path plus name,
alongside the existing time.Time and json.RawMessage checks — so it is
recognized wherever a named type is handled, not only where the fuzzy
name heuristic runs. That heuristic stays as the fallback for the
third-party UUID types (google/uuid, gofrs/uuid, strfmt.UUID), and an
explicit swagger:strfmt still overrules both.
The recognizer carries no build constraint, on purpose: codescan
compares types harvested from scanned sources and never imports uuid
itself, so a binary built by an older toolchain must still recognize a
go1.27 user type. Only the fixture and its integration test are guarded
by //go:build go1.27, since those genuinely cannot compile before then;
the predicate keeps its coverage on every supported toolchain through a
unit test that synthesizes the type instead of importing it.
An embedded uuid.UUID is unaffected — a non-struct, non-interface embed
still falls to the unsupported-type warning and contributes nothing.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
The model definitions tutorial now states the two rules side by side:
the go1.27 standard-library uuid.UUID matched by type identity, and any
other text-marshalling type named UUID matched by name. Both publish
{type: string, format: uuid}, and swagger:strfmt overrules either.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Change type
Please select: 🆕 New feature or enhancement|🔧 Bug fix'|📃 Documentation update
Short description
Fixes
Full description
Checklist