This repository was archived by the owner on Apr 29, 2026. It is now read-only.
feat: generic AnyUUID/AnyInt64 with variable prefix support#7
Merged
Conversation
Also fixes the four AnyInt64 lines in int64_test.go that blocked compilation.
e1bb64b to
3864372
Compare
david-littlefarmer
approved these changes
Apr 13, 2026
klaidliadon
added a commit
that referenced
this pull request
Apr 14, 2026
…)" This reverts commit 94c57ef.
VojtechVitek
pushed a commit
that referenced
this pull request
Apr 14, 2026
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Summary
Makes
AnyUUIDandAnyInt64generic overP Prefixer, adding compile-time-safe variable prefix support via an optionalVariablePrefixerinterface.VariablePrefixerinterface for prefix types that accept multiple string representationsAnyPrefixtype (backward-compat replacement for the old string-based prefix)AnyUUID[P]andAnyInt64[P]storePinstead ofstring, enabling type-safe prefix enumsParsePrefixif available, then validates viap.Prefix() != pref- one check for both variable and fixed prefixesVariant() Preturns the typed prefix value for switchingUUID[P],Int64[P],Prefixer, orsplitTypeidBefore / After
Before - manual string constants, manual validation, stringly-typed:
After - the type IS the validation:
ValidateApiKeyPrefix,PrefixForMode, and the manual string constants all disappear - the prefix type handles everything.For code that doesn't need variable prefixes,
AnyPrefixprovides backward compatibility:How prefix validation works
One check handles both paths. If
PimplementsVariablePrefixer,ParsePrefixsets*pto the matching variant (or leaves it at zero value on miss). Either way,p.Prefix() != prefcatches invalid input.Test plan
go vetclean