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 <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@google.com>
This commit is contained in:
Keith Randall 2023-05-30 10:54:21 -07:00
parent 2a129f3e8a
commit 094c75219a
1 changed files with 3 additions and 1 deletions

View 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 -->