So I'm looking to generate a random number in Go, and the recommended way of doing this is apparently to use something like this:
package main
import(
"fmt"
"math/rand"
"time"
)
func random(min, max int) int {
rand.Seed(time.Now().Unix())
return rand.Intn(max - min) + min
}
But this seems like a solution where the random number isn't random if two people run this script at the same time. The seed is apparently the time of execution, and this could very well be the same in some cases.
Isn't this a pretty inaccurate way of generating a random number? I ran it a couple times, and it just gives me the same number if I run it fast enough. Isn't there a better solution for a random number? Like, for example, using cryptography or something as the seed? Time just doesn't seem like the best seed.