Categorygithub.com/bsm/nanoid
repositorypackage
0.2.0
Repository: https://github.com/bsm/nanoid.git
Documentation: pkg.go.dev

# README

NanoID

Build Status GoDoc Go Report Card License

This is a port the original JavaScript library, a tiny, secure, URL-friendly, unique string ID generator for Go.

Examples

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"
}