rand

package
v0.0.0-...-9e07b7e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RandomLowercaseStringWithLen

func RandomLowercaseStringWithLen(n int) string

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

func RandomStringWithLen(n int) string

RandomStringWithLen returns a random string of specified length containing upper- and lowercase runes.

func RandomStringWithPrefix

func RandomStringWithPrefix(prefix string, n int) string

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

func NewSafeRand

func NewSafeRand(seed int64) *SafeRand

func (*SafeRand) Float64

func (sr *SafeRand) Float64() float64

func (*SafeRand) Int63

func (sr *SafeRand) Int63() int64

func (*SafeRand) Int63n

func (sr *SafeRand) Int63n(n int64) int64

func (*SafeRand) Intn

func (sr *SafeRand) Intn(n int) int

func (*SafeRand) Perm

func (sr *SafeRand) Perm(n int) []int

func (*SafeRand) Seed

func (sr *SafeRand) Seed(seed int64)

func (*SafeRand) Shuffle

func (sr *SafeRand) Shuffle(n int, swap func(i, j int))

func (*SafeRand) Uint32

func (sr *SafeRand) Uint32() uint32

func (*SafeRand) Uint64

func (sr *SafeRand) Uint64() uint64

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL