rand

package
v0.35.9 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2022 License: Apache-2.0 Imports: 4 Imported by: 1,249

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bytes

func Bytes(n int) []byte

Bytes returns n random bytes generated from math/rand's global default Source.

func NewRand

func NewRand() *mrand.Rand

NewRand returns a prng, that is seeded with OS randomness. The OS randomness is obtained from crypto/rand, however, like with any math/rand.Rand object none of the provided methods are suitable for cryptographic usage.

Note that the returned instance of math/rand's Rand is not suitable for concurrent use by multiple goroutines.

For concurrent use, call Reseed to reseed math/rand's default source and use math/rand's top-level convenience functions instead.

func Reseed added in v0.35.0

func Reseed()

Reseed conveniently re-seeds the default Source of math/rand with randomness obtained from crypto/rand.

Note that this does not make math/rand suitable for cryptographic usage.

Use math/rand's top-level convenience functions remain suitable for concurrent use by multiple goroutines.

func Str

func Str(length int) string

Str constructs a random alphanumeric string of given length from math/rand's global default Source.

func StrFromSource added in v0.35.1

func StrFromSource(r *mrand.Rand, length int) string

StrFromSource produces a random string of a specified length from the specified random source.

Types

This section is empty.

Jump to

Keyboard shortcuts

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