random

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2024 License: UNKNOWN, Apache-2.0, UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Overview

From AllInBits, Inc, TendermintClassic: github.com/tendermint/classic. License: Apache2.0.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RandBool

func RandBool() bool

func RandBytes

func RandBytes(n int) []byte

func RandFloat32

func RandFloat32() float32

func RandFloat64

func RandFloat64() float64

func RandInt

func RandInt() int

func RandInt16

func RandInt16() int16

func RandInt31

func RandInt31() int32

func RandInt31n

func RandInt31n(n int32) int32

func RandInt32

func RandInt32() int32

func RandInt63

func RandInt63() int64

func RandInt63n

func RandInt63n(n int64) int64

func RandInt64

func RandInt64() int64

func RandIntn

func RandIntn(n int) int

func RandPerm

func RandPerm(n int) []int

func RandStr

func RandStr(length int) string

func RandTime

func RandTime() time.Time

func RandUint

func RandUint() uint

func RandUint16

func RandUint16() uint16

func RandUint32

func RandUint32() uint32

func RandUint64

func RandUint64() uint64

func Seed

func Seed(seed int64)

Types

type Rand

type Rand struct {
	sync.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.

func NewRand

func NewRand() *Rand

func (*Rand) Bool

func (r *Rand) Bool() bool

Bool returns a uniformly random boolean

func (*Rand) Bytes

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

Bytes returns n random bytes generated from the internal prng.

func (*Rand) Float32

func (r *Rand) Float32() float32

func (*Rand) Float64

func (r *Rand) Float64() float64

func (*Rand) Int

func (r *Rand) Int() int

func (*Rand) Int16

func (r *Rand) Int16() int16

func (*Rand) Int31

func (r *Rand) Int31() int32

func (*Rand) Int31n

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

func (*Rand) Int32

func (r *Rand) Int32() int32

func (*Rand) Int63

func (r *Rand) Int63() int64

func (*Rand) Int63n

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

func (*Rand) Int64

func (r *Rand) Int64() int64

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.

func (*Rand) Perm

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

Perm returns a pseudo-random permutation of n integers in [0, n).

func (*Rand) Seed

func (r *Rand) Seed(seed int64)

func (*Rand) Str

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

Str constructs a random alphanumeric string of given length.

func (*Rand) Time

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

func (*Rand) Uint

func (r *Rand) Uint() uint

func (*Rand) Uint16

func (r *Rand) Uint16() uint16

func (*Rand) Uint32

func (r *Rand) Uint32() uint32

func (*Rand) Uint64

func (r *Rand) Uint64() uint64

Jump to

Keyboard shortcuts

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