Skip to content

revert: remove generic type parameter from AnyUUID/AnyInt64#8

Merged
VojtechVitek merged 1 commit intomasterfrom
revert-generic-any
Apr 14, 2026
Merged

revert: remove generic type parameter from AnyUUID/AnyInt64#8
VojtechVitek merged 1 commit intomasterfrom
revert-generic-any

Conversation

@klaidliadon
Copy link
Copy Markdown
Contributor

Summary

Why

The generic added complexity to a low-level package without meaningful downstream simplification. Prefix validation (matching a string prefix to an application-level enum) belongs in the application layer, not baked into the ID type via a type parameter.

Callers that need prefix validation can define helpers like:

func ParseApiKeyID(s string) (typeid.AnyUUID, ProjectMode, error) {
    id, err := typeid.ParseAnyUUID(s)
    if err != nil {
        return typeid.AnyUUID{}, 0, err
    }
    var mode ProjectMode
    if !mode.ParsePrefix(id.Prefix()) {
        return typeid.AnyUUID{}, 0, fmt.Errorf("invalid api key prefix: %q", id.Prefix())
    }
    return id, mode, nil
}

Test plan

  • All 70 existing tests pass
  • No breaking changes to UUID[P] or Int64[P] (compile-time-fixed prefix types unchanged)

Copy link
Copy Markdown
Contributor

@VojtechVitek VojtechVitek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you 👍

@VojtechVitek VojtechVitek merged commit 8de417d into master Apr 14, 2026
1 check passed
@VojtechVitek VojtechVitek deleted the revert-generic-any branch April 14, 2026 09:28
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.

2 participants