Skip to content

Stdlib UUID (go1.27) - #77

Merged
fredbi merged 2 commits into
go-openapi:masterfrom
fredbi:stdlib-uuid
Aug 1, 2026
Merged

Stdlib UUID (go1.27)#77
fredbi merged 2 commits into
go-openapi:masterfrom
fredbi:stdlib-uuid

Conversation

@fredbi

@fredbi fredbi commented Aug 1, 2026

Copy link
Copy Markdown
Member

Change type

Please select: 🆕 New feature or enhancement|🔧 Bug fix'|📃 Documentation update

Short description

Fixes

Full description

Checklist

  • I have signed all my commits with my name and email (see DCO. This does not require a PGP-signed commit
  • I have rebased and squashed my work, so only one commit remains
  • I have added tests to cover my changes.
  • I have properly enriched go doc comments in code.
  • I have properly documented any breaking change.

fredbi and others added 2 commits August 1, 2026 17:13
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>
@fredbi
fredbi merged commit dd9a25b into go-openapi:master Aug 1, 2026
24 checks passed
@fredbi
fredbi deleted the stdlib-uuid branch August 1, 2026 15:32
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.

1 participant