Documentation ¶
Index ¶
- Variables
- func ASCII(length int) (generator, error)
- func Canonic() (generator, error)
- func Custom(alphabet string, length int) (generator, error)
- func CustomASCII(alphabet string, length int) (generator, error)
- func CustomUnicode(alphabet string, length int) (generator, error)
- func MustCustomASCII(alphabet string, length int) generator
- func Standard(length int) (generator, error)
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidLength = errors.New("nanoid: length for ID is invalid (must be within 2-255)")
Functions ¶
func ASCII ¶ added in v1.2.0
Returns a mutexed buffereed NanoID generator that uses an alphabet of ASCII characters 40-126 inclusive.
Errors if length is not within 2-255 (incl).
func Canonic ¶ added in v1.4.0
func Canonic() (generator, error)
Returns a standard NanoID generator with canonic length (21)
i.e., nanoid.Standard(21)
func CustomASCII ¶ added in v1.1.0
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 ¶ added in v1.1.0
Returns a mutexed 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 ¶ added in v1.4.0
MustCustomASCII is a wrapper around CustomASCII but panics if any initialization error occurs.
Types ¶
This section is empty.