aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorTomas Aschan <[email protected]>2025-09-04 14:07:44 +0200
committerGitHub <[email protected]>2025-09-04 14:07:44 +0200
commitbe274af2a6d762e76dcb020967844bbcf3b3dbd4 (patch)
tree7fcd981ded4f4d1178988977094b5cae5a23852c /README.md
parent0491e5702ad2bb108bc519a5221bcc0f52aa9564 (diff)
parent5494e14f8cb125d5439aad4c37b344d7ea23e45b (diff)
Merge pull request #452 from thaJeztah/update_readme
README: update badges and minor linting fixes
Diffstat (limited to 'README.md')
-rw-r--r--README.md21
1 files changed, 15 insertions, 6 deletions
diff --git a/README.md b/README.md
index 388c4e5..35f97c2 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,7 @@
-[![Build Status](https://travis-ci.org/spf13/pflag.svg?branch=master)](https://travis-ci.org/spf13/pflag)
+[![Build Status](https://github.com/spf13/pflag/actions/workflows/ci.yaml/badge.svg)](https://github.com/spf13/pflag/actions/workflows/ci.yaml)
+![GitHub License](https://img.shields.io/github/license/spf13/pflag)
[![Go Report Card](https://goreportcard.com/badge/github.com/spf13/pflag)](https://goreportcard.com/report/github.com/spf13/pflag)
-[![GoDoc](https://godoc.org/github.com/spf13/pflag?status.svg)](https://godoc.org/github.com/spf13/pflag)
+[![PkgGoDev](https://pkg.go.dev/badge/github.com/spf13/pflag)](https://pkg.go.dev/github.com/spf13/pflag)
## Description
@@ -22,7 +23,7 @@ pflag is available using the standard `go get` command.
Install by running:
- go get github.com/spf13/pflag
+ go get github.com/spf13/pflag@latest
Run tests by running:
@@ -271,12 +272,15 @@ 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
+package main
+
import (
goflag "flag"
+
flag "github.com/spf13/pflag"
)
-var ip *int = flag.Int("flagname", 1234, "help message for flagname")
+var ip = flag.Int("flagname", 1234, "help message for flagname")
func main() {
flag.CommandLine.AddGoFlagSet(goflag.CommandLine)
@@ -296,17 +300,22 @@ will result in the `-v` flag being ignored. This happens because of the way pfla
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.
**Example**: You want to parse go test flags that are otherwise ignore by `pflag.Parse()`
+
```go
+package main
+
import (
goflag "flag"
+ "os"
+
flag "github.com/spf13/pflag"
)
-var ip *int = flag.Int("flagname", 1234, "help message for flagname")
+var ip = flag.Int("flagname", 1234, "help message for flagname")
func main() {
flag.CommandLine.AddGoFlagSet(goflag.CommandLine)
- flag.ParseSkippedFlags(os.Args[1:], goflag.CommandLine)
+ flag.ParseSkippedFlags(os.Args[1:], goflag.CommandLine)
flag.Parse()
}
```