Documentation
¶
Overview ¶
Package rand provides a pseudo-random number generator seeded with OS randomness.
Deprecated: This package will be removed in a future release. Users should migrate off this package, as its functionality will no longer be part of the exported interface.
Index ¶
- func Bool() booldeprecated
- func Bytes(n int) []bytedeprecated
- func Float32() float32deprecated
- func Float64() float64deprecated
- func Int() intdeprecated
- func Int16() int16deprecated
- func Int31() int32deprecated
- func Int31n(n int32) int32deprecated
- func Int32() int32deprecated
- func Int63() int64deprecated
- func Int63n(n int64) int64deprecated
- func Int64() int64deprecated
- func Intn(n int) intdeprecated
- func NewStdlibRand() *mrand.Rand
- func Perm(n int) []intdeprecated
- func Seed(seed int64)deprecated
- func Str(length int) stringdeprecated
- func Time() time.Timedeprecated
- func Uint() uintdeprecated
- func Uint16() uint16deprecated
- func Uint32() uint32deprecated
- func Uint64() uint64deprecated
- type Rand
- func NewRand() *Randdeprecated
- func (r *Rand) Bool() bool
- func (r *Rand) Bytes(n int) []byte
- func (r *Rand) Float32() float32deprecated
- func (r *Rand) Float64() float64deprecated
- func (r *Rand) Int() intdeprecated
- func (r *Rand) Int16() int16deprecated
- func (r *Rand) Int31() int32deprecated
- func (r *Rand) Int31n(n int32) int32deprecated
- func (r *Rand) Int32() int32deprecated
- func (r *Rand) Int63() int64deprecated
- func (r *Rand) Int63n(n int64) int64deprecated
- func (r *Rand) Int64() int64deprecated
- func (r *Rand) Intn(n int) int
- func (r *Rand) Perm(n int) []int
- func (r *Rand) Seed(seed int64)deprecated
- func (r *Rand) Str(length int) string
- func (r *Rand) Time() time.Timedeprecated
- func (r *Rand) Uint() uintdeprecated
- func (r *Rand) Uint16() uint16deprecated
- func (r *Rand) Uint32() uint32deprecated
- func (r *Rand) Uint64() uint64deprecated
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewStdlibRand ¶
Make a new stdlib rand source. Its up to the caller to ensure that the rand source is not called in parallel. The failure mode of calling the returned rand multiple times in parallel is repeated values across threads. Deprecated: This function will be removed in a future release. Do not use.
Types ¶
type Rand ¶
Rand is a prng, that is seeded with OS randomness. The OS randomness is obtained from crypto/rand, however none of the provided methods are suitable for cryptographic usage. They all utilize math/rand's prng internally.
All of the methods here are suitable for concurrent use. This is achieved by using a mutex lock on all of the provided methods. Deprecated: This struct will be removed in a future release. Do not use.
func (*Rand) Bool ¶
Bool returns a uniformly random boolean. Deprecated: This function will be removed in a future release. Do not use.
func (*Rand) Bytes ¶
Bytes returns n random bytes generated from the internal prng. Deprecated: This function will be removed in a future release. Do not use.
func (*Rand) Intn ¶
Intn returns, as an int, a uniform pseudo-random number in the range [0, n). It panics if n <= 0. Deprecated: This function will be removed in a future release. Do not use.
func (*Rand) Perm ¶
Perm returns a pseudo-random permutation of n integers in [0, n). Deprecated: This function will be removed in a future release. Do not use.
func (*Rand) Str ¶
Str constructs a random alphanumeric string of given length. Deprecated: This function will be removed in a future release. Do not use.