Skip to content

Commit ad7dc8a

Browse files
committed
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 <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Russ Cox <rsc@golang.org>
1 parent e6eaf39 commit ad7dc8a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: src/math/rand/rand.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ var globalRand = New(new(lockedSource))
315315
// Alternately, set GODEBUG=randautoseed=0 in the environment
316316
// before making any calls to functions in this package.
317317
//
318-
// Note: Programs that call Seed and then expect a specific sequence
318+
// Deprecated: Programs that call Seed and then expect a specific sequence
319319
// of results from the global random source (using functions such as Int)
320320
// can be broken when a dependency changes how much it consumes
321321
// from the global random source. To avoid such breakages, programs

0 commit comments

Comments
 (0)