nanoid

package
v1.13.1-rc.1 Latest Latest
Warning

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

Go to latest
Published: May 19, 2024 License: Apache-2.0 Imports: 6 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 GenerateLinuxInterfaceName

func GenerateLinuxInterfaceName() (string, error)

GenerateLinuxInterfaceName - returns a random interface name with "nsm" prefix to achieve a 1% chance of name collision, you need to generate approximately 68 billon names

func GenerateString

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

GenerateString 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