Go语言标准库功能详解
1. 随机数生成相关
1.1 Rand类型函数
Rand 类型提供了一系列用于生成随机数的函数:
- func (r *Rand) Int63n(n int64) int64 :生成一个范围在 [0, n) 的63位随机整数。
- func (r *Rand) Intn(n int) int :生成一个范围在 [0, n) 的随机整数。
- func (r *Rand) NormFloat64() float64 :生成一个服从标准正态分布的浮点数。
- func (r *Rand) Perm(n int) []int :返回一个长度为 n 的随机排列的整数切片。
- func (r *Rand) Read(p []byte) (n int, err error) :将随机字节填充到 p 切片中。
- func (r *Rand) Seed(seed int64) :设置随机数生成器的种子。
- func (r *Rand) Shuffle(n int, swap func(i, j int)) :对 n 个元素进行随机洗牌。
- func (r *Rand) Uint32() uint32 </
超级会员免费看
订阅专栏 解锁全文

被折叠的 条评论
为什么被折叠?



