RandIntInRange
Returns a random integer in the specified range.
- Use
rand.Intn()to generate a random number between0and the distance betweenminandmaxand addminto it.
import "math/rand"
func RandIntInRange(min, max int) int {
return rand.Intn(max-min) + min
}RandIntInRange(0, 5) // 2