id

package
v2.150.0 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("id: generator not found")

ErrNotFound for id.

Module for fx.

Functions

This section is empty.

Types

type Config

type Config struct {
	Kind string `yaml:"kind,omitempty" json:"kind,omitempty" toml:"kind,omitempty"`
}

Config for id.

func (*Config) IsEnabled added in v2.115.0

func (c *Config) IsEnabled() bool

IsEnabled for id.

type Generator

type Generator interface {
	// Generate an identifier.
	Generate() string
}

Generator to generate an identifier.

func NewGenerator

func NewGenerator(config *Config, reader rand.Reader) (Generator, error)

NewGenerator from config.

type KSUID

type KSUID struct{}

KSUID generator.

func (*KSUID) Generate

func (k *KSUID) Generate() string

Generate a KSUID.

type NanoID

type NanoID struct{}

NanoID generator.

func (*NanoID) Generate

func (n *NanoID) Generate() string

Generate a NanoID.

type ULID

type ULID struct {
	// contains filtered or unexported fields
}

ULID generator.

func NewULID

func NewULID(reader rand.Reader) *ULID

NewULID creates a new ULID generator.

func (*ULID) Generate

func (k *ULID) Generate() string

Generate a ULID.

type UUID

type UUID struct{}

UUID generator.

func (*UUID) Generate

func (g *UUID) Generate() string

Generate a UUID.

type XID

type XID struct{}

XID generator.

func (*XID) Generate

func (x *XID) Generate() string

Generate an XID.

Jump to

Keyboard shortcuts

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