I feel like this should be blatantly obvious, however google is failing me.
Really simple, how do I get a random member of a slice?
a := {1, 2, 3, 4, 5, 6, 7, 8, 9}
fmt.Println(randomMember(a))
>>> 4
I can see math/rand can generate arbitrary random numbers of various types but I can't figure out how to generate a random between 0 and x or between x and y.
Aucun commentaire:
Enregistrer un commentaire