Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Float64 ¶
func Float64() float64
Float64 returns, as a float64, a pseudo-random number in the half-open interval [0.0,1.0).
func Int32 ¶ added in v2.12.0
func Int32() int32
Int32 returns a non-negative pseudo-random 31-bit integer as an int32.
func Int64 ¶ added in v2.12.0
func Int64() int64
Int64 returns a non-negative pseudo-random 63-bit integer as an int64.
func N ¶ added in v2.12.0
func N[Int constraints.Integer](n Int) Int
N returns a pseudo-random number in the half-open interval [0,n) from the default Source. The type parameter Int can be any integer type. It panics if n <= 0.
func N_s ¶ added in v2.12.0
func N_s[Int constraints.Integer](s Source, n Int) Int
N_s returns a pseudo-random number in the half-open interval [0,n) from the given Source. The type parameter Int can be any integer type. It panics if n <= 0.
func Perm ¶
Perm returns, as a slice of n ints, a pseudo-random permutation of the integers in the half-open interval [0,n).
Types ¶
type Rand ¶ added in v2.12.0
type Rand struct {
// contains filtered or unexported fields
}
A Rand is a source of random numbers.
func New ¶ added in v2.12.0
New returns a new Rand that uses random values from src to generate other random values.
func (*Rand) Float64 ¶ added in v2.12.0
Float64 returns, as a float64, a pseudo-random number in the half-open interval [0.0,1.0).
func (*Rand) Int32 ¶ added in v2.12.0
Int32 returns a non-negative pseudo-random 31-bit integer as an int32.
func (*Rand) Int64 ¶ added in v2.12.0
Int64 returns a non-negative pseudo-random 63-bit integer as an int64.
func (*Rand) Perm ¶ added in v2.12.0
Perm returns, as a slice of n ints, a pseudo-random permutation of the integers in the half-open interval [0,n).
func (*Rand) Shuffle ¶ added in v2.12.0
Shuffle pseudo-randomizes the order of elements. n is the number of elements. Shuffle panics if n < 0. swap swaps the elements with indexes i and j.