Documentation
¶
Index ¶
- Variables
- func Must[T any](x T, err error) T
- type XUID
- func FromKey(key string) (*XUID, error)
- func FromKeyPrefix(key, prefix string) (*XUID, error)
- func FromUUID(u uuid.UUID, prefix string) (*XUID, error)
- func MustParse(s string) *XUID
- func MustParseUUID(inputUuid, prefix string) *XUID
- func New(prefix string) *XUID
- func NewRandom(prefix string) (*XUID, error)
- func Parse(s string) (*XUID, error)
- func ParsePrefix(s, prefix string) (*XUID, error)
- func ParseUUID(inputUuid, prefix string) (*XUID, error)
Constants ¶
This section is empty.
Variables ¶
var (
ErrBadPrefix = errors.New("xuid: bad prefix")
)
Functions ¶
Types ¶
type XUID ¶
func FromKey ¶ added in v0.1.6
FromKey returns a fixed ID based on a given key that can be guaranteed to always have the same ID as long as the key is the same value. This can be used for a Util/Ref object that have fixed IDs for a given key.
func FromKeyPrefix ¶ added in v0.1.6
FromKeyPrefix returns a fixed ID based on the key and prefix passed and is guaranteed to always return the same ID as long as the parameters are the same. This can be used for objects that need to keep the same ID no matter on which environment this runs.
func MustParseUUID ¶
func New ¶
New is a shorthand for Must(NewRandom(prefix)) and will always return a new xuid with the given prefix, or panic if for some reason the random generator does not work.
func ParsePrefix ¶ added in v0.1.8
ParsePrefix will parse the provided string and ensure the prefix matches the passed parameter, or return a ErrBadPrefix-based error if not.