random

package
v1.43.3 Latest Latest
Warning

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

Go to latest
Published: May 5, 2025 License: Apache-2.0 Imports: 4 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CommonTLDs = []string{
	"com",
	"org",
	"net",
}

CommonTLDs contains the 3 most common DNS TLDs.

Functions

func RandDigits

func RandDigits(n int) string

func RandDigitsRange

func RandDigitsRange(rangeMin int, rangeMax int) string

RandDigitsRange generates a random numeric string of length [min,max).

func RandDomain added in v1.43.0

func RandDomain() string

RandDomain generates a random domain name with a common TLDs. The domain will be between 8 and 14 characters.

func RandEmail added in v1.43.0

func RandEmail() string

RandEmail generates a random email address using common domain TLDs. The largest size of the generated domain will be 23 characters and smallest will be 13 characters. The goal is not to generate a set of RFC valid domains, but simple lower case emails that are valid for most automated account registration or usage, so these might be "too simple" or for some uses.

func RandHex

func RandHex(n int) string

func RandHexRange

func RandHexRange(rangeMin int, rangeMax int) string

RandHexRange generates a random hex string of length [min,max).

func RandIntRange added in v1.0.6

func RandIntRange(rangeMin int, rangeMax int) int

RandIntRange generates an `int` between [min,max).

func RandLetters

func RandLetters(n int) string

RandLetters generates a random alpha string of length n.

func RandLettersNoBadChars added in v1.0.12

func RandLettersNoBadChars(n int, badchars []rune) string

RandLettersNoBadChars generates a random alpha string with no bad chars of length n. This will return an empty string if the caller badchars all "letters".

func RandLettersRange

func RandLettersRange(rangeMin int, rangeMax int) string

RandLettersRange generates a random alpha string of length [min,max).

func RandPositiveInt added in v1.0.6

func RandPositiveInt(rangeMax int) int

RandPositiveInt generates a non-negative crypto-random number in the half-open interval [0,max).

Types

This section is empty.

Jump to

Keyboard shortcuts

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