tid

package
v1.121.0 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2024 License: MPL-2.0 Imports: 5 Imported by: 7

Documentation

Index

Constants

View Source
const KindAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"

KindAlphabet is the set of characters that can be used as the first character of a TID. 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 TID, kind byte) bool

IsKind returns true if the TID has the specified kind.

func IsKindAndValid

func IsKindAndValid(id TID, kind byte) bool

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

func IsValid

func IsValid(id TID) bool

IsValid returns true if the TID is a valid TID.

Types

type TID

type TID string

TID 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) (TID, error)

FromString converts a string to a TID.

func FromStringOfKind

func FromStringOfKind(id string, kind byte) (TID, error)

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

func MustNewTID added in v1.112.0

func MustNewTID(kind byte) TID

MustNewTID creates a new TID with a random value and the specified kind. If an error occurs, this function panics.

func NewTID

func NewTID(kind byte) (TID, error)

NewTID creates a new TID 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