Skip to content

Import path: gitlab.soludian.com/soludian/fountain/libs/base/rand_util

rand_util

go
import "gitlab.soludian.com/soludian/fountain/libs/base/rand_util"

Index

func RandomAlphaOrNumeric

go
func RandomAlphaOrNumeric(count uint, letters, numbers bool) string

Creates a random string whose length is the number of characters specified.

Characters will be chosen from the set of alpha-numeric characters as indicated by the arguments.

Param count - the length of random string to create Param letters - if true, generated string will include

alphabetic characters

Param numbers - if true, generated string will include

numeric characters

func RandomAlphabetic

go
func RandomAlphabetic(count uint) string

Creates a random string whose length is the number of characters specified. Characters will be chosen from the set of alphabetic characters.

func RandomAlphanumeric

go
func RandomAlphanumeric(count uint) string

Creates a random string whose length is the number of characters specified. Characters will be chosen from the set of alpha-numeric characters.

func RandomAscii

go
func RandomAscii(count uint) string

Creates a random string whose length is the number of characters specified.

Characters will be chosen from the set of characters whose ASCII value is between 32 and 126 (inclusive).

func RandomInt

go
func RandomInt(min, max int) int

RandomInt return a random int at the [min, max] Intn returns, as an int, a non-negative pseudo-random number in the half-open interval [0,n] from the default Source. It panics if n <= 0

Usage:

RandomInt(10, 99)
RandomInt(100, 999)
RandomInt(1000, 9999)

func RandomNumber

go
func RandomNumber(len int) string

RandomNumber func

func RandomNumeric

go
func RandomNumeric(count uint) string

Creates a random string whose length is the number of characters specified. Characters will be chosen from the set of numeric characters.

func RandomSpec0

go
func RandomSpec0(count uint, start, end int, letters, numbers bool, chars []rune) string

Creates a random string based on a variety of options, using supplied source of randomness.

If start and end are both 0, start and end are set to ' ' and 'z', the ASCII printable characters, will be used, unless letters and numbers are both false, in which case, start and end are set to 0 and math.MaxInt32.

If set is not nil, characters between start and end are chosen.

This method accepts a user-supplied rand.Rand instance to use as a source of randomness. By seeding a single rand.Rand instance with a fixed seed and using it for each call, the same random sequence of strings can be generated repeatedly and predictably.

func RandomSpec1

go
func RandomSpec1(count uint, start, end int, letters, numbers bool) string

Creates a random string whose length is the number of characters specified.

Characters will be chosen from the set of alpha-numeric characters as indicated by the arguments.

Param count - the length of random string to create Param start - the position in set of chars to start at Param end - the position in set of chars to end before Param letters - if true, generated string will include

alphabetic characters

Param numbers - if true, generated string will include

numeric characters

func RandomString

go
func RandomString(count uint) string

func RandomStringSpec0

go
func RandomStringSpec0(count uint, set []rune) string

func RandomStringSpec1

go
func RandomStringSpec1(count uint, set string) string

Generated by gomarkdoc