math/rand: add example for Intn func

This commit is contained in:
Vladimir Kovpak 2019-03-13 11:38:33 +02:00
parent fe05bddecb
commit 2adfcd2d5a
1 changed files with 3 additions and 2 deletions

View File

@ -142,8 +142,9 @@ func ExampleShuffle_slicesInUnison() {
}
func ExampleIntn() {
// 86 - arbitrary value just for sake of example,
// so people don't blindly hard-code this value into program use meaningful one.
// Seeding with the same value results in the same random sequence each run.
// For different numbers, seed with a different value, such as
// time.Now().UnixNano(), which yields a constantly-changing number.
rand.Seed(86)
fmt.Println(rand.Intn(100))
fmt.Println(rand.Intn(100))