乱数のseed
from Go
乱数のseed
しばしば main.go の頭に書いたりする、あとは rand.Int() など普通に使えばよい
code:rand.go
import (
crand "crypto/rand"
"math"
"math/big"
"math/rand"
)
func init() {
seed, _ := crand.Int(crand.Reader, big.NewInt(math.MaxInt64))
rand.Seed(seed.Int64())
}