publicid
URL-safe, non-sequential public IDs from a fixed lowercase nanoid alphabet.
go get github.com/ubgo/publicid
- Language
- Go
- Go version
- 1.24
- Core deps
- 1 direct
- Latest tag
- v0.1.0
- License
- Apache-2.0
- Go modules
- 1
Code from the README
package main
import (
"fmt"
"github.com/ubgo/publicid"
)
func main() {
id, err := publicid.New()
if err != nil { panic(err) }
fmt.Println(id) // e.g. "k7n3p9q2x8m4r6t1v5y0w8z3"
}if err := publicid.Validate("user_id", input); err != nil {
return err
}
// or with custom length:
if err := publicid.ValidateN("short_code", code, 7); err != nil { ... }From the publicid README.