rand

package
v2.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool deprecated

func Bool() bool

Deprecated: This function will be removed in a future release. Do not use.

func Bytes deprecated

func Bytes(n int) []byte

Deprecated: This function will be removed in a future release. Do not use.

func Float32 deprecated

func Float32() float32

Deprecated: This function will be removed in a future release. Do not use.

func Float64 deprecated

func Float64() float64

Deprecated: This function will be removed in a future release. Do not use.

func Int deprecated

func Int() int

Deprecated: This function will be removed in a future release. Do not use.

func Int16 deprecated

func Int16() int16

Deprecated: This function will be removed in a future release. Do not use.

func Int31 deprecated

func Int31() int32

Deprecated: This function will be removed in a future release. Do not use.

func Int31n deprecated

func Int31n(n int32) int32

Deprecated: This function will be removed in a future release. Do not use.

func Int32 deprecated

func Int32() int32

Deprecated: This function will be removed in a future release. Do not use.

func Int63 deprecated

func Int63() int64

Deprecated: This function will be removed in a future release. Do not use.

func Int63n deprecated

func Int63n(n int64) int64

Deprecated: This function will be removed in a future release. Do not use.

func Int64 deprecated

func Int64() int64

Deprecated: This function will be removed in a future release. Do not use.

func Intn deprecated

func Intn(n int) int

Deprecated: This function will be removed in a future release. Do not use.

func NewStdlibRand

func NewStdlibRand() *mrand.Rand

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.

func Perm deprecated

func Perm(n int) []int

Deprecated: This function will be removed in a future release. Do not use.

func Seed deprecated

func Seed(seed int64)

Deprecated: This function will be removed in a future release. Do not use.

func Str deprecated

func Str(length int) string

Deprecated: This function will be removed in a future release. Do not use.

func Time deprecated

func Time() time.Time

Deprecated: This function will be removed in a future release. Do not use.

func Uint deprecated

func Uint() uint

Deprecated: This function will be removed in a future release. Do not use.

func Uint16 deprecated

func Uint16() uint16

Deprecated: This function will be removed in a future release. Do not use.

func Uint32 deprecated

func Uint32() uint32

Deprecated: This function will be removed in a future release. Do not use.

func Uint64 deprecated

func Uint64() uint64

Deprecated: This function will be removed in a future release. Do not use.

Types

type Rand

type Rand struct {
	cmtsync.Mutex
	// contains filtered or unexported fields
}

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 NewRand deprecated

func NewRand() *Rand

Deprecated: This function will be removed in a future release. Do not use.

func (*Rand) Bool

func (r *Rand) Bool() bool

Bool returns a uniformly random boolean. Deprecated: This function will be removed in a future release. Do not use.

func (*Rand) Bytes

func (r *Rand) Bytes(n int) []byte

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) Float32 deprecated

func (r *Rand) Float32() float32

Deprecated: This function will be removed in a future release. Do not use.

func (*Rand) Float64 deprecated

func (r *Rand) Float64() float64

Deprecated: This function will be removed in a future release. Do not use.

func (*Rand) Int deprecated

func (r *Rand) Int() int

Deprecated: This function will be removed in a future release. Do not use.

func (*Rand) Int16 deprecated

func (r *Rand) Int16() int16

Deprecated: This function will be removed in a future release. Do not use.

func (*Rand) Int31 deprecated

func (r *Rand) Int31() int32

Deprecated: This function will be removed in a future release. Do not use.

func (*Rand) Int31n deprecated

func (r *Rand) Int31n(n int32) int32

Deprecated: This function will be removed in a future release. Do not use.

func (*Rand) Int32 deprecated

func (r *Rand) Int32() int32

Deprecated: This function will be removed in a future release. Do not use.

func (*Rand) Int63 deprecated

func (r *Rand) Int63() int64

Deprecated: This function will be removed in a future release. Do not use.

func (*Rand) Int63n deprecated

func (r *Rand) Int63n(n int64) int64

Deprecated: This function will be removed in a future release. Do not use.

func (*Rand) Int64 deprecated

func (r *Rand) Int64() int64

Deprecated: This function will be removed in a future release. Do not use.

func (*Rand) Intn

func (r *Rand) Intn(n int) int

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

func (r *Rand) Perm(n int) []int

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) Seed deprecated

func (r *Rand) Seed(seed int64)

Deprecated: This function will be removed in a future release. Do not use.

func (*Rand) Str

func (r *Rand) Str(length int) string

Str constructs a random alphanumeric string of given length. Deprecated: This function will be removed in a future release. Do not use.

func (*Rand) Time deprecated

func (r *Rand) Time() time.Time

Deprecated: This function will be removed in a future release. Do not use.

func (*Rand) Uint deprecated

func (r *Rand) Uint() uint

Deprecated: This function will be removed in a future release. Do not use.

func (*Rand) Uint16 deprecated

func (r *Rand) Uint16() uint16

Deprecated: This function will be removed in a future release. Do not use.

func (*Rand) Uint32 deprecated

func (r *Rand) Uint32() uint32

Deprecated: This function will be removed in a future release. Do not use.

func (*Rand) Uint64 deprecated

func (r *Rand) Uint64() uint64

Deprecated: This function will be removed in a future release. Do not use.

Jump to

Keyboard shortcuts

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