randutil

package
v0.2.32 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2019 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Reader *randReader

Reader is a global, shared instance of a cryptographically strong pseudo- random generator. It uses blake2b as its hashing function. Reader is safe for concurrent use by multiple goroutines.

Functions

func BigIntN added in v0.2.32

func BigIntN(n *big.Int) *big.Int

BigIntN returns a uniform random *big.Int in [0,n). It panics if n <= 0.

func Bits

func Bits(b []byte)

func Bytes added in v0.2.32

func Bytes(n int) []byte

Bytes a helper function that returns n bytes of random data.

func Int

func Int(min int, max int) int

Int returns a random integer in range [min, max].

func IntN added in v0.2.32

func IntN(n int) int

IntN returns a uniform random int in [0,n). It panics if n <= 0.

func Ints

func Ints(from, to, size int) []int

Ints returns a random integer array with the specified from, to and size.

func Perm added in v0.2.32

func Perm(n int) []int

Perm returns a random permutation of the integers [0,n).

func Probability

func Probability(prob float64) bool

Probability

func Random added in v0.2.32

func Random(ss []string) []string

Random return random string from string slice

func Read added in v0.2.32

func Read(b []byte)

Read is a helper function that calls Reader.Read on b. It always fills b completely.

func Shuffle added in v0.2.32

func Shuffle(n int, swap func(i, j int))

Shuffle randomizes the order of elements. n is the number of elements. It panics if n < 0. swap swaps the elements with indexes i and j.

func String

func String(n int) string

func UUID added in v0.2.32

func UUID(length int64) string

UUID return uuid

func Uint64n added in v0.2.32

func Uint64n(n uint64) uint64

Uint64n returns a uniform random uint64 in [0,n). It panics if n == 0.

Types

This section is empty.

Jump to

Keyboard shortcuts

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