aboutsummaryrefslogtreecommitdiff
path: root/flag.go
diff options
context:
space:
mode:
authorSebastiaan van Stijn <[email protected]>2025-09-01 21:10:46 +0200
committerSebastiaan van Stijn <[email protected]>2025-09-01 23:10:00 +0200
commitc5b9e989df31c5d19573e50d6188550ad51a971e (patch)
treeb82907c198f0abb6dcb3f887bd4036c6db414cff /flag.go
parent10438578954bba2527fe5cae3684d4532b064bbe (diff)
remove uses of errors.Is, which requires go1.13
Commit 1bf832c6fec8a35a8c1d61e5fb14f5ce404197ef introduced the use of `errors.Is`, which was added in [go1.13], but the `go.mod` was not updated to reflect this, causing compile failures on go1.12: docker run -it --rm -v ./:/pflag -w /pflag golang:1.12 sh -c 'go test -v ./...' # github.com/spf13/pflag [github.com/spf13/pflag.test] ./flag.go:1190:7: undefined: errors.Is ./flag.go:1219:7: undefined: errors.Is ./bool_func_test.go:86:28: cannot use stdFSet (type *flag.FlagSet) as type BoolFuncFlagSet in argument to runCase: *flag.FlagSet does not implement BoolFuncFlagSet (missing BoolFunc method) ... As the error that is tested will not be wrapped, we can omit the `errors.Is`, and instead continue doing a straight comparison. [go1.13]: https://pkg.go.dev/[email protected]#Is Signed-off-by: Sebastiaan van Stijn <[email protected]>
Diffstat (limited to 'flag.go')
-rw-r--r--flag.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/flag.go b/flag.go
index eeed1e9..b9f0839 100644
--- a/flag.go
+++ b/flag.go
@@ -1185,7 +1185,7 @@ func (f *FlagSet) Parse(arguments []string) error {
case ContinueOnError:
return err
case ExitOnError:
- if errors.Is(err, ErrHelp) {
+ if err == ErrHelp {
os.Exit(0)
}
fmt.Fprintln(f.Output(), err)
@@ -1214,7 +1214,7 @@ func (f *FlagSet) ParseAll(arguments []string, fn func(flag *Flag, value string)
case ContinueOnError:
return err
case ExitOnError:
- if errors.Is(err, ErrHelp) {
+ if err == ErrHelp {
os.Exit(0)
}
fmt.Fprintln(f.Output(), err)