func GenRandomBytes(size int) (randomBytes []byte) {
rand.Seed(time.Now().UnixNano())
randomBytes = make([]byte, size)
rand.Read(randomBytes)
return randomBytes
}
Context
Pay attention to this line, otherwise everytime randomBytes
is the same.
rand.Seed(time.Now().UnixNano())
最新评论