]> Cypherpunks repositories - gostls13.git/commitdiff
doc/go1.20: document math/rand autoseed and deprecation of Seed
authorRuss Cox <rsc@golang.org>
Mon, 21 Nov 2022 22:34:16 +0000 (17:34 -0500)
committerRuss Cox <rsc@golang.org>
Tue, 22 Nov 2022 15:56:48 +0000 (15:56 +0000)
Change-Id: Ie557f3841781ac47f4044a395106a2e5b13e9695
Reviewed-on: https://go-review.googlesource.com/c/go/+/452561
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
doc/go1.20.html

index 211425e0dc1d38d2dc6784c21f3d919d53c6f5ee..3d49dd2442e4448136162fd676ba2af19c49108a 100644 (file)
@@ -612,12 +612,17 @@ proxyHandler := &httputil.ReverseProxy{
 
 <dl id="math/rand"><dt><a href="/pkg/math/rand/">math/rand</a></dt>
   <dd>
-    <p><!-- https://go.dev/issue/54880 -->
-      TODO: <a href="https://go.dev/issue/54880">https://go.dev/issue/54880</a>: seed global generator randomly
+    <p><!-- https://go.dev/issue/54880 --><!-- CL 436955 -->
+      The <a href="/pkg/math/rand/">math/rand</a> package now automatically seeds
+      the global random number generator
+      (used by top-level functions like <code>Float64</code> and <code>Int</code>) with a random value,
+      and the top-level <a href="/pkg/math/rand/#Seed"><code>Seed</code></a> function has been deprecated.
+      Programs that need a reproducible sequence of random numbers
+      should prefer to allocate their own random source, using <code>rand.New(rand.NewSource(seed))</code>.
     </p>
-
-    <p><!-- CL 436955 -->
-      TODO: <a href="https://go.dev/cl/436955">https://go.dev/cl/436955</a>: math/rand: deprecate Read
+    <p>
+      Programs that need the earlier consistent global seeding behavior can set
+      <code>GODEBUG=randautoseed=0</code> in their environment.
     </p>
   </dd>
 </dl><!-- math/rand -->