Skip to content

Commit

Permalink
doc: document new panic behavior of flag definition after Set
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
randall77 committed May 30, 2023
1 parent 2a129f3 commit 094c752
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion doc/go1.21.html
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,9 @@ <h3 id="minor_library_changes">Minor changes to the library</h3>
</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 -->
Expand Down

0 comments on commit 094c752

Please sign in to comment.