Skip to content

Commit

Permalink
math/rand: deprecate Seed
Browse files Browse the repository at this point in the history
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 <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Run-TryBot: Russ Cox <[email protected]>
  • Loading branch information
rsc committed Nov 16, 2022
1 parent e6eaf39 commit ad7dc8a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/math/rand/rand.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ad7dc8a

Please sign in to comment.