-
Notifications
You must be signed in to change notification settings - Fork 341
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
Using pflag precludes the use of any other package written to use flag #63
Comments
You can use AddGoFlagSet to add all |
There is another use case that is still problematic. There are cases where the program is passed flag style arguments automatically, which then fail when parsed by pflag. A glaring example of this is in fact "go test" - which passes flags such as -test.v -test.trace etc. After importing flags from flag into pflag, "go test" fails. |
Reopening this to bring attention to fellow developers. |
I also ran into this while using pflags with flags from Here is a workaround. It works by seperating the test flags and all other flags. Then it hands them off to the correct flag parser. Note you need go 1.6rc2(might work with rc1) as there is a bug in 1.5 which makes |
I extended @epelc's gist to also filter goflags with values. It now works with https://gist.github.com/doublerebel/8b95c5c118e958e495d2#file-your_test-go-L13 Wouldn't hurt to have this as a feature such as |
I believe this commit cb88ea7 adds built in support for passing through test flags. It's convenient that the go flag package uses a single dash followed by a string of characters containing a dot as that's invalid for posix shorthand flags and is easily identifiable and ignorable. Closing this for now as it feels the core issue is resolved. If someone wants to create another issue requesting a new |
This is because if you mix packages that use pflag with those that use flag, it requires you to call both flag.Parse() anf pflag.Parse() - one or both of which will fail.
This seems to be a crippling requirement because if I choose to use pflag, I am precluded from using any other third party package that uses flag.
The text was updated successfully, but these errors were encountered: