Files
go-cart-actor/pkg/profile/id.go
T
mats aa8b2bdedc
Build and Publish / BuildAndDeployAmd64 (push) Failing after 5s
Build and Publish / BuildAndDeployArm64 (push) Failing after 6s
all the refactor
2026-06-28 17:51:52 +02:00

29 lines
677 B
Go

package profile
import (
"fmt"
"git.k6n.net/mats/platform/uid"
)
// ProfileId is a 64-bit profile identifier with a compact base62 string form.
type ProfileId uid.ID
// String returns the canonical base62 encoding.
func (id ProfileId) String() string { return uid.ID(id).String() }
// NewProfileId generates a cryptographically random non-zero id.
func NewProfileId() (ProfileId, error) {
id, err := uid.New()
if err != nil {
return 0, fmt.Errorf("NewProfileId: %w", err)
}
return ProfileId(id), nil
}
// ParseProfileId parses a base62 string into a ProfileId.
func ParseProfileId(s string) (ProfileId, bool) {
id, ok := uid.Parse(s)
return ProfileId(id), ok
}