nanoid

package
v1.2.185 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidLength = errors.New("nanoid: length for ID is invalid (must be within 2-255)")

Functions

This section is empty.

Types

type NanoIdGenerator

type NanoIdGenerator = func() string

func ASCII

func ASCII(length int) (NanoIdGenerator, error)

ASCII returns a mutex-ed buffered NanoID generator that uses an alphabet of subset ASCII characters 40-126 inclusive. Errors if length is not within 2-255 (incl).

func Canonic

func Canonic() (NanoIdGenerator, error)

Canonic is a wrapper around Standard but panics if any initialization error occurs.

func CustomASCII

func CustomASCII(alphabet string, length int) (NanoIdGenerator, error)

CustomASCII returns a Nano ID generator which uses a custom ASCII alphabet. Uses less memory than CustomUnicode by only supporting ASCII. For Unicode support use nanoid.CustomUnicode. Errors if alphabet is not valid ASCII or if length is not within 2-255 (incl).

func CustomUnicode

func CustomUnicode(alphabet string, length int) (NanoIdGenerator, error)

CustomUnicode returns a mutex-ed buffered NanoID generator which uses a custom alphabet that can contain non-ASCII (Unicode). Uses more memory by supporting unicode. For ASCII-only, use nanoid.CustomASCII. Errors if length is within 2-255 (incl).

func MustCustomASCII

func MustCustomASCII(alphabet string, length int) NanoIdGenerator

MustCustomASCII is a wrapper around CustomASCII but panics if any initialization error occurs.

func Standard

func Standard(length int) (NanoIdGenerator, error)

Standard returns a mutex-ed buffered NanoID generator.

Jump to

Keyboard shortcuts

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