id

package
v3.11.40 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2025 License: Apache-2.0 Imports: 8 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultNanoidAlphabet = "6789BCDFGHJKLMNPQRTWbcdfghjkmnpqrtwz"

DefaultNanoidAlphabet is the alphabet used for ID characters by default

View Source
var DefaultNanoidSize = 16

DefaultNanoidSize is the size used for ID by default To get uuid like collision specify 21

Functions

func MustNew added in v3.11.23

func MustNew(opts ...Option) string

Must is the same as New but fatals on error

func New

func New(opts ...Option) (string, error)

New returns new id or error

func ToUUID added in v3.11.24

func ToUUID(s string) uuid.UUID

Types

type Generator added in v3.11.23

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

func (*Generator) MustNew added in v3.11.23

func (g *Generator) MustNew() string

func (*Generator) New added in v3.11.23

func (g *Generator) New() (string, error)

type Option

type Option func(*Options)

Option func signature

func WithNanoidAlphabet added in v3.11.23

func WithNanoidAlphabet(alphabet string) Option

WithNanoidAlphabet specifies alphabet to use

func WithNanoidSize added in v3.11.23

func WithNanoidSize(size int) Option

WithNanoidSize specifies generated id size

func WithUUIDNode added in v3.11.23

func WithUUIDNode(node [6]byte) Option

WithUUIDNode specifies node component for UUIDv8

type Options

type Options struct {
	Type           Type
	NanoidAlphabet string
	NanoidSize     int
	UUIDNode       [6]byte
}

Options contains id deneration options

func NewOptions

func NewOptions(opts ...Option) Options

NewOptions returns new Options struct filled by opts

type Type added in v3.11.23

type Type int
const (
	TypeUnspecified Type = iota
	TypeNanoid
	TypeUUIDv8
)

Jump to

Keyboard shortcuts

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