Skip to content

Commit 094c752

Browse files
committed
doc: document new panic behavior of flag definition after Set
For #57411 Change-Id: I56c112bb03dde24c2e2643c9b72ce06158a8e717 Reviewed-on: https://go-review.googlesource.com/c/go/+/499278 TryBot-Bypass: Keith Randall <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: Keith Randall <[email protected]>
1 parent 2a129f3 commit 094c752

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

doc/go1.21.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,9 @@ <h3 id="minor_library_changes">Minor changes to the library</h3>
456456
</p>
457457

458458
<p><!-- CL 480215 -->
459-
TODO: <a href="https://go.dev/cl/480215">https://go.dev/cl/480215</a>: flag: panic if a flag is defined after being set
459+
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.
460+
<p>
461+
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.
460462
</p>
461463
</dd>
462464
</dl><!-- flag -->

0 commit comments

Comments
 (0)