rand

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: May 26, 2021 License: Apache-2.0 Imports: 4 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool added in v0.0.6

func Bool() bool

func Bytes

func Bytes(n int) []byte

func Float32 added in v0.0.6

func Float32() float32

func Float64 added in v0.0.6

func Float64() float64

func Int added in v0.0.6

func Int() int

func Int16 added in v0.0.6

func Int16() int16

func Int31 added in v0.0.6

func Int31() int32

func Int31n added in v0.0.6

func Int31n(n int32) int32

func Int32 added in v0.0.6

func Int32() int32

func Int63 added in v0.0.6

func Int63() int64

func Int63n added in v0.0.6

func Int63n(n int64) int64

func Int64 added in v0.0.6

func Int64() int64

func Intn added in v0.0.6

func Intn(n int) int

func Perm added in v0.0.6

func Perm(n int) []int

func Seed added in v0.0.7

func Seed(seed int64)

func Str

func Str(length int) string

func Time added in v0.0.6

func Time() time.Time

func Uint added in v0.0.6

func Uint() uint

func Uint16 added in v0.0.6

func Uint16() uint16

func Uint32 added in v0.0.6

func Uint32() uint32

func Uint64 added in v0.0.6

func Uint64() uint64

Types

type Rand added in v0.0.6

type Rand struct {
	tmsync.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 added in v0.0.7

func (r *Rand) Bool() bool

Bool returns a uniformly random boolean

func (*Rand) Bytes added in v0.0.7

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

Bytes returns n random bytes generated from the internal prng.

func (*Rand) Float32 added in v0.0.7

func (r *Rand) Float32() float32

func (*Rand) Float64 added in v0.0.7

func (r *Rand) Float64() float64

func (*Rand) Int added in v0.0.7

func (r *Rand) Int() int

func (*Rand) Int16 added in v0.0.7

func (r *Rand) Int16() int16

func (*Rand) Int31 added in v0.0.7

func (r *Rand) Int31() int32

func (*Rand) Int31n added in v0.0.7

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

func (*Rand) Int32 added in v0.0.7

func (r *Rand) Int32() int32

func (*Rand) Int63 added in v0.0.7

func (r *Rand) Int63() int64

func (*Rand) Int63n added in v0.0.7

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

func (*Rand) Int64 added in v0.0.7

func (r *Rand) Int64() int64

func (*Rand) Intn added in v0.0.7

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 added in v0.0.7

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

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

func (*Rand) Seed added in v0.0.7

func (r *Rand) Seed(seed int64)

func (*Rand) Str added in v0.0.7

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

Str constructs a random alphanumeric string of given length.

func (*Rand) Time added in v0.0.7

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

func (*Rand) Uint added in v0.0.7

func (r *Rand) Uint() uint

func (*Rand) Uint16 added in v0.0.7

func (r *Rand) Uint16() uint16

func (*Rand) Uint32 added in v0.0.7

func (r *Rand) Uint32() uint32

func (*Rand) Uint64 added in v0.0.7

func (r *Rand) Uint64() uint64

Jump to

Keyboard shortcuts

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