https://github.com/bsm/nanoid
golang nanoid unique-id
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/bsm/nanoid
- Owner: bsm
- License: apache-2.0
- Created: 2020-02-19T10:16:35.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2023-06-02T02:34:00.000Z (about 3 years ago)
- Last Synced: 2025-03-22T19:02:33.798Z (about 1 year ago)
- Topics: golang, nanoid, unique-id
- Language: Go
- Size: 13.7 KB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NanoID
[](https://travis-ci.org/bsm/nanoid)
[](http://godoc.org/github.com/bsm/nanoid)
[](https://goreportcard.com/report/github.com/bsm/nanoid)
[](https://opensource.org/licenses/Apache-2.0)
This is a port the original [JavaScript](https://github.com/ai/nanoid) library, a tiny, secure, URL-friendly, unique string ID generator for [Go](https://golang.org).
## Examples
```go
package main
import (
"fmt"
"github.com/bsm/nanoid"
)
func main() {
// Generate a base64-encoded ID with default length.
fmt.Println(nanoid.New()) // => "AAXTFo7Gdp2kwyvZDySP6"
// Generate a base64-encoded ID with custom length.
fmt.Println(nanoid.NewSize(16)) // => "fSYXVjtyrXN8Bw33"
// Use custom encoding.
fmt.Println(nanoid.Base32.MustGenerate(16)) // => "WOEJC4M2HXXNSXQ7"
}
```