You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Question:
Should "flag.commandLine" be exported similar to how
"http.DefaultServeMux" is exported?
Proposal:
Rename "flag.commandLine" to "flag.DefaultFlagSet". Include this in
Go1 because it's a backwards compatible change.
Use Case:
I'm writing a config file parser that uses a flag.FlagSet to determine what options are
allowed.
I would like to be able to write a function to operate on any "*flag.FlagSet"
including "flag.commandLine". The exact function I'd like to be able to write
is this:
func DoStuff(fs *flag.FlagSet) {
if fs == nil {
fs = flag.DefaultFlagSet
}
...
}
Abuse Potential:
Not much. Someone could replace "flag.DefaultFlagSet" or set it equal to nil.
Neither would be a problem in practice.
If this is not a crazy idea let me know and I'll make a patch.
Thanks!
The text was updated successfully, but these errors were encountered:
I tripped over this while writing a test for flag manipulation. It would have been nice
to have commandLine exported so I could more easily switch between it and a fake FlagSet.
by seth.bunce:
The text was updated successfully, but these errors were encountered: