-
Notifications
You must be signed in to change notification settings - Fork 18k
flag: Set stops parsing arguments when encountering an unknown flag even in ContinueOnError mode #70167
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
Comments
The problem with extra output was solved using fSet.SetOutput(io.Discard) |
As the docs for ContinueOnError states, it only controls if flag parsing returns an error or exits the program. In general flag cannot continue since it doesn't know if ia flag is a boolean type. Closing as working as intended. |
In my opinion, adding a check to see if the next argument (if there is one) is a flag or not is not a big problem. |
Does it make sense to reopen this same thing as a proposal? |
Go version
go version go1.23.1 linux/amd64
Output of
go env
in your module/workspace:What did you do?
I'm trying to make a package that will contain public variables based on the command line arguments of the process that imported the package. This could be useful in many places, but at the moment I want to know if the -test.v flag is set and the coverage settings
https://go.dev/play/p/b87bzeDhaFO
What did you see happen?
flag provided but not defined: -notdefined
false
Program exited.
What did you expect to see?
The err variable contains a value that can be processed not through strings.Contains but in a more correct way through errors.As/Is
And most importantly, the Verbose variable is set to true
The text was updated successfully, but these errors were encountered: