diff options
| author | Alexander Brand <[email protected]> | 2016-06-10 12:09:29 -0400 |
|---|---|---|
| committer | Alexander Brand <[email protected]> | 2016-06-09 13:16:51 -0400 |
| commit | 253e78081c8b881fd5837570636965e524784ca1 (patch) | |
| tree | 68ea82416301b0dabac8b1c0985d40a0bfd798b5 | |
| parent | cb88ea77998c3f024757528e3305022ab50b43be (diff) | |
Document AddGoFlagSet method in the README file
| -rw-r--r-- | README.md | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -244,6 +244,25 @@ It is possible to mark a flag as hidden, meaning it will still function as norma flags.MarkHidden("secretFlag") ``` +## Supporting Go flags when using pflag +In order to support flags defined using Go's `flag` package, they must be added to the `pflag` flagset. This is usually necessary +to support flags defined by third-party dependencies (e.g. `golang/glog`). + +**Example**: You want to add the Go flags to the `CommandLine` flagset +```go +import ( + goflag "flag" + flag "github.com/spf13/pflag" +) + +var ip *int = flag.Int("flagname", 1234, "help message for flagname") + +func main() { + flag.CommandLine.AddGoFlagSet(goflag.CommandLine) + flag.Parse() +} +``` + ## More info You can see the full reference documentation of the pflag package |
