Documentation
¶
Overview ¶
Package rand allows developers to inject rand.Rand interfaces rather the math/rand.Rand struct. This allows for easier testing with two benefits:
- Developers can inject either a locking or unlocking Rand implementation (the built-in rand locks global methods and does not lock rand.Rand struct methods.
- The rand.Rand interface allows more straightforward faking. The built-in rand.Rand struct has differemt mechanisms for extracting various kinds of ints from bit fields, which can make fakes unnecessarily hard to create. For one such fake, see [xkcdrand](github.com/inlined/xkcdrand).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Rand ¶
type Rand interface {
ExpFloat64() float64
Float32() float32
Float64() float64
Int() int
Int31() int32
Int31n(n int32) int32
Int63() int64
Int63n(n int64) int64
Intn(n int) int
NormFloat64() float64
Perm(n int) []int
Read(p []byte) (n int, err error)
Seed(seed int64)
Shuffle(n int, swap func(i, j int))
Uint32() uint32
Uint64() uint64
}
Rand is an injectable interface that matches the struct of math/rand.Rand
Click to show internal directories.
Click to hide internal directories.