uuid

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2025 License: Apache-2.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const KindAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"

KindAlphabet is the set of characters that can be used as the first character of a ID. The kind has no intrinsic meaning, but can be used to differentiate between different types of ids.

Variables

This section is empty.

Functions

func IsKind

func IsKind(id ID, kind byte) bool

IsKind returns true if the ID has the specified kind.

func IsKindAndValid

func IsKindAndValid(id ID, kind byte) bool

IsKindAndValid returns true if the ID is a valid ID with the specified kind.

func IsValid

func IsValid(id ID) bool

IsValid returns true if the ID is a valid ID.

Types

type ID

type ID string

ID is a unique identifier. These are similar to v4 UUIDs, but are shorter and have a different format that includes a kind byte as the first character. TIDs are 17 characters long, are URL safe, and contain 96 bits of entropy.

func FromString

func FromString(id string) ID

FromString converts a string to a ID.

func FromStringOfKind

func FromStringOfKind(id string, kind byte) ID

FromStringOfKind converts a string to a ID and verifies that it has the specified kind.

func New

func New(kind byte) ID

New creates a new ID with a random value and the specified kind.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL