Documentation
¶
Index ¶
Constants ¶
const ( Numbers = 1 << iota Letters = 1 << iota Upper = 1 << iota Lower = 1 << iota )
options to generate random string
Variables ¶
This section is empty.
Functions ¶
func CheckOption ¶
CheckOption checks if the given option is valid.
func Int63 ¶
func Int63() int64
Int63 returns a non-negative pseudo-random 63-bit integer as an int64.
func String ¶
String same as StringWithOption(length, Numbers | Letters), use a separate function with constants to improve performance.
func StringWithOption ¶
StringWithOption returns a random string with the given length and options. The options can be combined using bitwise OR operation. The basic idea of this function is to generate a random number and map it to a character in the given options. This algorithm and idea is from https://stackoverflow.com/a/31832326 with an optimization for thead-safe by pre-allocating a bulk of mutexes and rand.Source. NOTE: this function will not check the options, length, so you should make sure the options and length are valid and correct before calling this function. can use CheckOption to check the option, length and number.
Types ¶
This section is empty.