Documentation ¶
Overview ¶
Package random provides utilities and functions for generating random data.
Index ¶
Constants ¶
const Digits = "0123456789"
Character sets that you can use when passing into RandomString
const LowerLetters = "abcdefghijklmnopqrstuvwxyz"
const SpecialChars = "<>[]{}()-_*%&/?\"'\\"
const UpperLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Variables ¶
var Base62Chars = Digits + UpperLetters + LowerLetters
Functions ¶
func RandomString ¶
RandomString generates a random string of length strLength, composing only of characters in allowedChars. Based on code here: http://stackoverflow.com/a/9543797/483528 For convenience, the random package exposes various character sets you can use for the allowedChars parameter. Here are a few examples:
// Only lower case chars + digits random.RandomString(6, random.Digits + random.LowerLetters)
// alphanumerics + special chars random.RandomString(6, random.Base62Chars + random.SpecialChars)
// Only alphanumerics (base62) random.RandomString(6, random.Base62Chars)
// Only abc random.RandomString(6, "abc")
Types ¶
This section is empty.