Documentation
¶
Index ¶
- Variables
- type NanoIdGenerator
- func ASCII(length int) (NanoIdGenerator, error)
- func Canonic() (NanoIdGenerator, error)
- func CustomASCII(alphabet string, length int) (NanoIdGenerator, error)
- func CustomUnicode(alphabet string, length int) (NanoIdGenerator, error)
- func MustCustomASCII(alphabet string, length int) NanoIdGenerator
- func Standard(length int) (NanoIdGenerator, error)
Constants ¶
This section is empty.
Variables ¶
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.