From 2adfcd2d5a592ef4c63da781240a391da89b5d9e Mon Sep 17 00:00:00 2001 From: Vladimir Kovpak Date: Wed, 13 Mar 2019 11:38:33 +0200 Subject: [PATCH] math/rand: add example for Intn func --- src/math/rand/example_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/math/rand/example_test.go b/src/math/rand/example_test.go index 22af1c29b2..4107613555 100644 --- a/src/math/rand/example_test.go +++ b/src/math/rand/example_test.go @@ -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))