Documentation
¶
Overview ¶
随机数生成工具, 更多随机数生成方法,可对照标准库“math/rand”
Index ¶
- func Bytes(n int) []byte
- func Digits(n int) string
- func Duration(min, max time.Duration) time.Duration
- func Int(min, max int) int
- func Intn(max int) int
- func Letters(n int) string
- func Meet(num, total int) bool
- func MeetProb(prob float32) bool
- func Perm(n int) []int
- func StrRand(s string, n int) string
- func String(n int, symbols ...bool) string
- func Symbols(n int) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Intn ¶
Intn 方法返回大于等0且不大于max的随机整数,即:[0, max]
Note that: 1. The `max` can only be greater than 0, or else it returns `max` directly; 2. The result is greater than or equal to 0, but less than `max`; 3. The result number is 32bit and less than math.MaxUint32.
func Meet ¶
Meet 用于指定一个数num和总数total,往往 num<=total,并随机计算是否满足num/total的概率。 例如,Meet(1, 100)将会随机计算是否满足百分之一的概率。
func MeetProb ¶
MeetProb 用于给定一个概率浮点数prob,往往 prob<=1.0,并随机计算是否满足该概率。 例如,MeetProb(0.005)将会随机计算是否满足千分之五的概率。
func StrRand ¶
StrRand 方法是一个比较高级的方法,用于从给定的字符列表中选择指定长度的随机字符串返回, 并且支持unicode字符,例如中文。例如,Str("中文123abc", 3)将可能会返回1a文的随机字符串。
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.