nanoid

package
v1.13.0-rc.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Overview

Package nanoid is a tiny, unique string ID generator

Index

Constants

View Source
const (
	// DefaultAlphabet is the default alphabet for the generator which can be used to generate kernel interface names
	DefaultAlphabet = "!\"#$&'()*+,-.012456789;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
)

Variables

This section is empty.

Functions

func New

func New(opt ...Option) func(int) (string, error)

New creates a new nanoid generator with specified options

func RandomString

func RandomString(size int, opt ...Option) (string, error)

RandomString generates a random string based on size. Original JavaScript implementation: https://github.com/ai/nanoid/blob/main/README.md

Types

type Option

type Option func(o *generatorOpts)

Option represents options for the string generator

func WithAlphabet

func WithAlphabet(alphabet string) Option

WithAlphabet sets a custom alphabet for the generator

func WithRandomByteGenerator

func WithRandomByteGenerator(generator io.Reader) Option

WithRandomByteGenerator sets a generator for random bytes generation

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL