Safe. It uses cryptographically strong random generator.
Compact. It uses more symbols than UUID (
and has the same number of unique options in just 22 symbols instead of 36.
Fast. Nanoid is as fast as UUID but can be used in URLs.
Via go get tool
$ go get github.com/matoous/go-nanoid
id, err := gonanoid.Nanoid()
Generate ID with custom alphabet and length
id, err := gonanoid.Generate("abcde", 54)
$ go test
If you use Go Nanoid in your project, please let me know!
If you have any issues, just feel free and open it in this repository, thanks!
The MIT License (MIT). Please see License File for more information.
Generate is a low-level function to change alphabet and ID size.
ID provides more golang idiomatic interface for generating IDs. Calling ID is shorter yet still clear `gonanoid.ID(20)` and it requires the lengths parameter by default.
func MustGenerate ¶
MustGenerate is the same as Generate but panics on error.