From 2cfd7967082efefa36b7f32bacc42e622e1bd29d Mon Sep 17 00:00:00 2001 From: Matthew Rothenberg Date: Wed, 1 Feb 2023 20:51:13 -0500 Subject: [PATCH] docs: global rand seed deprecated in go1.20 The math/rand package now automatically seeds the global random number generator with a random value, and the top-level Seed function has been deprecated. --- README.md | 2 -- examples/frequency/main.go | 4 ---- weightedrand_test.go | 2 +- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/README.md b/README.md index 20c1264..edd0c5d 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,6 @@ import ( ) func main() { - rand.Seed(time.Now().UTC().UnixNano()) // always seed random! - chooser, _ := weightedrand.NewChooser( weightedrand.NewChoice('🍒', 0), weightedrand.NewChoice('🍋', 1), diff --git a/examples/frequency/main.go b/examples/frequency/main.go index 08db4af..c4ee2ea 100644 --- a/examples/frequency/main.go +++ b/examples/frequency/main.go @@ -3,15 +3,11 @@ package main import ( "fmt" "log" - "math/rand" - "time" "github.com/mroth/weightedrand/v2" ) func main() { - rand.Seed(time.Now().UTC().UnixNano()) // always seed random! - c, err := weightedrand.NewChooser( weightedrand.NewChoice('🍒', 0), weightedrand.NewChoice('🍋', 1), diff --git a/weightedrand_test.go b/weightedrand_test.go index bcc8358..824eeb0 100644 --- a/weightedrand_test.go +++ b/weightedrand_test.go @@ -34,7 +34,7 @@ func Example() { *******************************************************************************/ func init() { - rand.Seed(time.Now().UTC().UnixNano()) + rand.Seed(time.Now().UTC().UnixNano()) // only necessary prior to go1.20 } const (