jeudi 17 septembre 2020

Random int stay the same upon being called multiple time [duplicate]

I have this code that generates a random number

func randomInt(min, max int) int {
    return min + rand.Intn(max-min)
}

func main() {
    println(randomInt(8, 12))
}

I then build it in the terminal with go build main.go and use it with mypath/main but it always return the same number : why ?

I use this mecanic in a code much more complex and it's really an issue.




Aucun commentaire:

Enregistrer un commentaire