import (
"math/rand"
"time"
)
func main() {
// NewSource takes int64 value which is returned by time.Now().UnixNano()
source := rand.NewSource(time.Now().UnixNano())
r := rand.New(source)
number :=r.Intn(100) // from 0 to 100 generate a random int number
}
Last active
May 26, 2020 11:19
-
-
Save vyasriday/c31ba861e02c683ee7150d61c792691e to your computer and use it in GitHub Desktop.
Generating a random number in go using rand and time package
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment