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
@@ -22,7 +23,7 @@ pflag is available using the standard `go get` command.
22
23
23
24
Install by running:
24
25
25
-
go get github.com/spf13/pflag
26
+
go get github.com/spf13/pflag@latest
26
27
27
28
Run tests by running:
28
29
@@ -271,12 +272,15 @@ to support flags defined by third-party dependencies (e.g. `golang/glog`).
271
272
272
273
**Example**: You want to add the Go flags to the `CommandLine` flagset
273
274
```go
275
+
package main
276
+
274
277
import (
275
278
goflag "flag"
279
+
276
280
flag "github.com/spf13/pflag"
277
281
)
278
282
279
-
varip*int= flag.Int("flagname", 1234, "help message for flagname")
283
+
varip = flag.Int("flagname", 1234, "help message for flagname")
280
284
281
285
funcmain() {
282
286
flag.CommandLine.AddGoFlagSet(goflag.CommandLine)
@@ -296,17 +300,22 @@ will result in the `-v` flag being ignored. This happens because of the way pfla
296
300
To work around this, you can use the `ParseSkippedFlags` function, which ensures that go test's flags are parsed separately using the standard flag package.
297
301
298
302
**Example**: You want to parse go test flags that are otherwise ignore by `pflag.Parse()`
303
+
299
304
```go
305
+
package main
306
+
300
307
import (
301
308
goflag "flag"
309
+
"os"
310
+
302
311
flag "github.com/spf13/pflag"
303
312
)
304
313
305
-
varip*int= flag.Int("flagname", 1234, "help message for flagname")
314
+
varip = flag.Int("flagname", 1234, "help message for flagname")
0 commit comments