Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/vet: reject flag.Parse during func init #33190

Open
rsc opened this issue Jul 19, 2019 · 0 comments

Comments

@rsc
Copy link
Contributor

commented Jul 19, 2019

In #31859, @cespare suggested rejecting flag.Parse during func init, which is always incorrect (other packages not yet initialized may want to define flags).

We could add a special runtime hook of some kind to allow flag to see whether main.main has started, but that would be unfortunate.
There also may be lots of code in the wild that does parse flags during init and kind of works out OK, and if it's working well enough we don't want to break it unnecessarily.

A vet check, on by default during go test, seems like the perfect compromise to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.