Documentation ¶
Index ¶
- func Bool() bool
- func Bytes(n int) []byte
- func Float32() float32
- func Float64() float64
- func Int() int
- func Int16() int16
- func Int31() int32
- func Int31n(n int32) int32
- func Int32() int32
- func Int63() int64
- func Int63n(n int64) int64
- func Int64() int64
- func Intn(n int) int
- func NewStdlibRand() *mrand.Rand
- func Perm(n int) []int
- func Seed(seed int64)
- func Str(length int) string
- func Time() time.Time
- func Uint() uint
- func Uint16() uint16
- func Uint32() uint32
- func Uint64() uint64
- type Rand
- func (r *Rand) Bool() bool
- func (r *Rand) Bytes(n int) []byte
- func (r *Rand) Float32() float32
- func (r *Rand) Float64() float64
- func (r *Rand) Int() int
- func (r *Rand) Int16() int16
- func (r *Rand) Int31() int32
- func (r *Rand) Int31n(n int32) int32
- func (r *Rand) Int32() int32
- func (r *Rand) Int63() int64
- func (r *Rand) Int63n(n int64) int64
- func (r *Rand) Int64() int64
- func (r *Rand) Intn(n int) int
- func (r *Rand) Perm(n int) []int
- func (r *Rand) Seed(seed int64)
- func (r *Rand) Str(length int) string
- func (r *Rand) Time() time.Time
- func (r *Rand) Uint() uint
- func (r *Rand) Uint16() uint16
- func (r *Rand) Uint32() uint32
- func (r *Rand) Uint64() uint64
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.
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.
func (*Rand) Intn ¶
Intn returns, as an int, a uniform pseudo-random number in the range [0, n). It panics if n <= 0.