From: Russ Cox Date: Wed, 16 Nov 2022 17:04:32 +0000 (-0500) Subject: math/rand: deprecate Seed X-Git-Tag: go1.20rc1~215 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=ad7dc8ad55e6540bbf285df869d4ee6c12fff0e7;p=gostls13.git math/rand: deprecate Seed Programs that call Seed and then expect a specific sequence of results from the global random source (using functions such as Int) can be broken when a dependency changes how much it consumes from the global random source. To avoid such breakages, programs that need a specific result sequence should use NewRand(NewSource(seed)) to obtain a random generator that other packages cannot access. Fixes #56319. Change-Id: Idac33991b719d2c71f109f51dacb3467a649e01e Reviewed-on: https://go-review.googlesource.com/c/go/+/451375 Reviewed-by: Ian Lance Taylor TryBot-Result: Gopher Robot Run-TryBot: Russ Cox --- diff --git a/src/math/rand/rand.go b/src/math/rand/rand.go index 0157d7198b..77d7e86fb2 100644 --- a/src/math/rand/rand.go +++ b/src/math/rand/rand.go @@ -315,7 +315,7 @@ var globalRand = New(new(lockedSource)) // Alternately, set GODEBUG=randautoseed=0 in the environment // before making any calls to functions in this package. // -// Note: Programs that call Seed and then expect a specific sequence +// Deprecated: Programs that call Seed and then expect a specific sequence // of results from the global random source (using functions such as Int) // can be broken when a dependency changes how much it consumes // from the global random source. To avoid such breakages, programs