fastrand

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base62

func Base62(s int) string

Base62 generates a random base62 string with length of n

func Base64

func Base64(n int) string

Base64 generates a random base64 string with length of n

func Bytes

func Bytes(n int) []byte

Bytes generates n random bytes

func Hex

func Hex(n int) string

Hex generates a random hex string with length of n e.g: 67aab2d956bd7cc621af22cfb169cba8

func Perm

func Perm(n uint32) []uint32

Perm

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

func Probability

func Probability(prob uint32) bool

Probability 小于prob的概率, prob is in the range [0,1000)

func Random

func Random(ss []string) []string

Random

return random string from string slice

func Read

func Read(b []byte)

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

func Sampling

func Sampling(rate uint8) bool

Sampling 采样率, [rate] is in the range [0,100)

func Shuffle

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

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.

func String

func String(n int, letters ...string) string

String generates a random string using only letters provided in the letters parameter if user commit letters parameters, this function will use defLetters instead

func Uint32

func Uint32() uint32

Uint32 returns pseudorandom uint32. It is safe calling this function from concurrent goroutines.

func Uint32n

func Uint32n(maxN uint32) uint32

Uint32n returns pseudorandom uint32 in the range [0...maxN). It is safe calling this function from concurrent goroutines.

Types

This section is empty.

Jump to

Keyboard shortcuts

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