Documentation ¶
Index ¶
- func RandomLowercaseStringWithLen(n int) string
- func RandomString() string
- func RandomStringWithLen(n int) string
- func RandomStringWithPrefix(prefix string, n int) string
- type SafeRand
- func (sr *SafeRand) Float64() float64
- func (sr *SafeRand) Int63() int64
- func (sr *SafeRand) Int63n(n int64) int64
- func (sr *SafeRand) Intn(n int) int
- func (sr *SafeRand) Perm(n int) []int
- func (sr *SafeRand) Seed(seed int64)
- func (sr *SafeRand) Shuffle(n int, swap func(i, j int))
- func (sr *SafeRand) Uint32() uint32
- func (sr *SafeRand) Uint64() uint64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RandomLowercaseStringWithLen ¶ added in v1.8.0
RandomLowercaseStringWithLen returns a random string of specified length containing lowercase runes.
func RandomString ¶
func RandomString() string
RandomString returns a random string with a predefined length of 12.
func RandomStringWithLen ¶
RandomStringWithLen returns a random string of specified length containing upper- and lowercase runes.
func RandomStringWithPrefix ¶
RandomStringWithPrefix returns a random string of length n + len(prefix) with the given prefix, containing upper- and lowercase runes.
Types ¶
type SafeRand ¶
type SafeRand struct {
// contains filtered or unexported fields
}
SafeRand is a concurrency-safe source of pseudo-random numbers. The Go stdlib's math/rand.Source is not concurrency-safe. The global source in math/rand would be concurrency safe (due to its internal use of lockedSource), but it is prone to inter-package interference with the PRNG state. Also see https://github.com/cilium/cilium/issues/10988