import "math/rand"
n := rand.Intn(100) // n is a random int, 0 <= n < 100
f := rand.Float64() // f is a random float64, 0.0 <= f < 1.0
x := []string{"a", "b", "c", "d", "e"}
// shuffling the slice put its elements into a random order
rand.Shuffle(len(x), func(i, j int) {
x[i], x[j] = x[j], x[i]
})
// 设置随机种子
rand.Seed(time.Now().UnixNano())
标签:rand,Intn,int,random,基础,Golang,随机数
From: https://www.cnblogs.com/roadwide/p/17134943.html