Skip to content

Commit be274af

Browse files
authored
Merge pull request #452 from thaJeztah/update_readme
README: update badges and minor linting fixes
2 parents 0491e57 + 5494e14 commit be274af

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
[![Build Status](https://travis-ci.org/spf13/pflag.svg?branch=master)](https://travis-ci.org/spf13/pflag)
1+
[![Build Status](https://github.com/spf13/pflag/actions/workflows/ci.yaml/badge.svg)](https://github.com/spf13/pflag/actions/workflows/ci.yaml)
2+
![GitHub License](https://img.shields.io/github/license/spf13/pflag)
23
[![Go Report Card](https://goreportcard.com/badge/github.com/spf13/pflag)](https://goreportcard.com/report/github.com/spf13/pflag)
3-
[![GoDoc](https://godoc.org/github.com/spf13/pflag?status.svg)](https://godoc.org/github.com/spf13/pflag)
4+
[![PkgGoDev](https://pkg.go.dev/badge/github.com/spf13/pflag)](https://pkg.go.dev/github.com/spf13/pflag)
45

56
## Description
67

@@ -22,7 +23,7 @@ pflag is available using the standard `go get` command.
2223

2324
Install by running:
2425

25-
go get github.com/spf13/pflag
26+
go get github.com/spf13/pflag@latest
2627

2728
Run tests by running:
2829

@@ -271,12 +272,15 @@ to support flags defined by third-party dependencies (e.g. `golang/glog`).
271272

272273
**Example**: You want to add the Go flags to the `CommandLine` flagset
273274
```go
275+
package main
276+
274277
import (
275278
goflag "flag"
279+
276280
flag "github.com/spf13/pflag"
277281
)
278282

279-
var ip *int = flag.Int("flagname", 1234, "help message for flagname")
283+
var ip = flag.Int("flagname", 1234, "help message for flagname")
280284

281285
func main() {
282286
flag.CommandLine.AddGoFlagSet(goflag.CommandLine)
@@ -296,17 +300,22 @@ will result in the `-v` flag being ignored. This happens because of the way pfla
296300
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.
297301

298302
**Example**: You want to parse go test flags that are otherwise ignore by `pflag.Parse()`
303+
299304
```go
305+
package main
306+
300307
import (
301308
goflag "flag"
309+
"os"
310+
302311
flag "github.com/spf13/pflag"
303312
)
304313

305-
var ip *int = flag.Int("flagname", 1234, "help message for flagname")
314+
var ip = flag.Int("flagname", 1234, "help message for flagname")
306315

307316
func main() {
308317
flag.CommandLine.AddGoFlagSet(goflag.CommandLine)
309-
flag.ParseSkippedFlags(os.Args[1:], goflag.CommandLine)
318+
flag.ParseSkippedFlags(os.Args[1:], goflag.CommandLine)
310319
flag.Parse()
311320
}
312321
```

0 commit comments

Comments
 (0)