I'm currently generating random data in Go, and I'm having an issue with generating random numbers in sequence with Go's math/rand package. For example, if I need to generate a list of random integers, even with my function:
func random(min, max int) int {
rand.Seed(time.Now().UTC().UnixNano())
return rand.Intn(max - min) + min
}
Consecutive numbers returned by random(0,100) will still always be equivalent (I guess because they are randomly produced at the same time in nano seconds?) Is there any way around this?
Aucun commentaire:
Enregistrer un commentaire