Documentation ¶
Overview ¶
Package random implements some basic functions to generate random int and string.
Index ¶
- Constants
- func RandBool() bool
- func RandBoolSlice(length int) []bool
- func RandBytes(length int) []byte
- func RandFloat(min, max float64, precision int) float64
- func RandFloats(n int, min, max float64, precision int) []float64
- func RandInt(min, max int) int
- func RandIntSlice(length, min, max int) []int
- func RandLower(length int) string
- func RandNumeral(length int) string
- func RandNumeralOrLetter(length int) string
- func RandString(length int) string
- func RandStringSlice(charset string, sliceLen, strLen int) []string
- func RandSymbolChar(length int) string
- func RandUniqueIntSlice(n, min, max int) []int
- func RandUpper(length int) string
- func UUIdV4() (string, error)
Constants ¶
const ( MaximumCapacity = math.MaxInt>>1 + 1 Numeral = "0123456789" LowwerLetters = "abcdefghijklmnopqrstuvwxyz" UpperLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" Letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" SymbolChars = "!@#$%^&*()_+-=[]{}|;':\",./<>?" )
Variables ¶
This section is empty.
Functions ¶
func RandBool ¶ added in v1.4.4
func RandBool() bool
RandBool generates a random boolean value (true or false).
func RandBoolSlice ¶ added in v1.4.4
RandBoolSlice generates a random boolean slice of specified length.
func RandBytes ¶
RandBytes generate random byte slice. Play: https://go.dev/play/p/EkiLESeXf8d
func RandFloat ¶ added in v1.4.3
RandFloat generate random float64 number between [min, max) with specific precision.
func RandFloats ¶ added in v1.4.3
RandFloats generate a slice of random float64 numbers of length n that do not repeat.
func RandIntSlice ¶ added in v1.4.4
RandIntSlice generates a slice of random integers. The generated integers are between min and max (exclusive).
func RandNumeral ¶ added in v1.3.3
RandNumeral generate a random numeral string of specified length.
func RandNumeralOrLetter ¶ added in v1.3.3
RandNumeralOrLetter generate a random numeral or alpha string of specified length.
func RandString ¶
RandString generate random alpha string of specified length.
func RandStringSlice ¶ added in v1.4.4
RandString generate a slice of random string of length strLen based on charset. chartset should be one of the following: random.Numeral, random.LowwerLetters, random.UpperLetters random.Letters, random.SymbolChars, random.AllChars. or a combination of them.
func RandSymbolChar ¶ added in v1.4.3
RandSymbolChar generate a random symbol char of specified length. symbol chars: !@#$%^&*()_+-=[]{}|;':\",./<>?.
func RandUniqueIntSlice ¶ added in v1.4.0
RandUniqueIntSlice generate a slice of random int of length n that do not repeat.
Types ¶
This section is empty.