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

flag: export commandLine var #4209

Closed
gopherbot opened this issue Oct 8, 2012 · 5 comments
Closed

flag: export commandLine var #4209

gopherbot opened this issue Oct 8, 2012 · 5 comments
Milestone

Comments

@gopherbot
Copy link

by seth.bunce:

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!
@dsymonds
Copy link
Contributor

dsymonds commented Oct 8, 2012

Comment 1:

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.

Labels changed: added go1.1maybe, packagechange, removed go1.1.

@rsc
Copy link
Contributor

rsc commented Dec 30, 2012

Comment 2:

Labels changed: added priority-later, removed priority-triage.

Status changed to Thinking.

@robpike
Copy link
Contributor

robpike commented Mar 7, 2013

Comment 3:

Labels changed: removed go1.1maybe.

@rsc
Copy link
Contributor

rsc commented Jul 30, 2013

Comment 4:

Labels changed: added go1.2maybe, feature.

@robpike
Copy link
Contributor

robpike commented Aug 8, 2013

Comment 5:

This issue was closed by revision 6ac93e2.

Status changed to Fixed.

@rsc rsc added this to the Go1.2 milestone Apr 14, 2015
@rsc rsc removed the go1.2maybe label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants