]> Cypherpunks.ru repositories - gostls13.git/commitdiff
doc: document new panic behavior of flag definition after Set
authorKeith Randall <khr@golang.org>
Tue, 30 May 2023 17:54:21 +0000 (10:54 -0700)
committerKeith Randall <khr@golang.org>
Tue, 30 May 2023 22:16:11 +0000 (22:16 +0000)
For #57411

Change-Id: I56c112bb03dde24c2e2643c9b72ce06158a8e717
Reviewed-on: https://go-review.googlesource.com/c/go/+/499278
TryBot-Bypass: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@google.com>
doc/go1.21.html

index 085b81dbf7a0814e62d20579e02b4148b1408228..e08f84c384b400960982c9418f2620f659106861 100644 (file)
@@ -456,7 +456,9 @@ Do not send CLs removing the interior tags from such phrases.
     </p>
 
     <p><!-- CL 480215 -->
-      TODO: <a href="https://go.dev/cl/480215">https://go.dev/cl/480215</a>: flag: panic if a flag is defined after being set
+      A flag definition (via <code>Bool</code>, <code>BoolVar</code>, <code>Int</code>, <code>IntVar</code>, etc.) will panic if <code>Set</code> has already been called on a flag with the same name.
+      <p>
+      This change is intended to detect cases where <a href="#language">changes in initialization order</a> cause flag operations to occur in a different order than expected. In many cases the fix to this problem is to introduce a explicit package dependence to correctly order the definition before any <code>Set</code> operations.
     </p>
   </dd>
 </dl><!-- flag -->