generator

package
v2.24.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

View Source
const Base32IDSizeBytes = 18

Base32IDSizeBytes is the length of a base 32 identifier in bytes in the system.

View Source
const IDSizeBytes = 32

IDSizeBytes is the length of an identifier in bytes in the system.

View Source
const MaxPrefix = 8

MaxPrefix is the maximum ID prefix length

Variables

View Source
var (
	// AlphaRunes is the runes [a-zA-Z]
	AlphaRunes = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
	// HexRunes are those digits and characters that can occur as part of
	// a hexadecimal number representation (0-9, A-F)
	HexRunes = []rune("0123456789ABCDEF")
	// DigitRunes are the 10 digits [0-9]
	DigitRunes = []rune("0123456789")
	// SymbolRunes are the special characters [!@#$%`'^&*()_+]
	SymbolRunes = []rune("!@#$%`'^&*()_+")
	// UnreservedSymbolRunes are the symbols that are not reserved in URLs
	UnreservedSymbolRunes = ("-._~")
)

Functions

func Base32ID

func Base32ID(prefix IDPrefix) string

Base32ID creates a random id starting with prefix to idSize length

func Bytes

func Bytes(n int) []byte

Bytes array of length n with random values.

func Code

func Code(length int) string

Code returns random letters & numbers of the requested length

func Distinguishable added in v2.18.3

func Distinguishable(length int) string

Distinguishable returns random alphanumerics of the requested length, excluding similar characters (e.g. 0, O, 1, l, I)

func Email

func Email() string

Email returns a fake email address for testing

func Hex

func Hex(length int) string

Hex returns a hex string of the requested length

func HexColor

func HexColor() string

HexColor returns a 7 length string from #000000 - #FFFFFF

func ID

func ID(prefix IDPrefix) string

ID creates a random id starting with prefix to idSize length

func Int

func Int() int

Int returns a random Int

func Int16

func Int16() int16

Int16 returns a random Int16

func Int32

func Int32() int32

Int32 returns a random Int32

func Name

func Name() string

Name returns a fake name for testing

func Password

func Password(length int) string

Password generates a random password of a given length

func Secret

func Secret() string

Secret returns a string that is suitable as a Salt or a Client Secret

func String

func String(length int) string

String returns random letters of the requested length

func TestID

func TestID() string

TestID returns an ID with a random prefix for testing purposes

func UInt16

func UInt16() uint16

UInt16 returns a random UInt16

func UInt32

func UInt32() uint32

UInt32 returns a random UInt32

func Year

func Year() int32

Year returns random year between 1976 and 2017

Types

type IDPrefix

type IDPrefix string

IDPrefix is the human readable prefix that is attached to a generated ID

Jump to

Keyboard shortcuts

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