Skip to content

Commit c5b9e98

Browse files
committed
remove uses of errors.Is, which requires go1.13
Commit 1bf832c 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]>
1 parent 1043857 commit c5b9e98

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

flag.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ func (f *FlagSet) Parse(arguments []string) error {
11851185
case ContinueOnError:
11861186
return err
11871187
case ExitOnError:
1188-
if errors.Is(err, ErrHelp) {
1188+
if err == ErrHelp {
11891189
os.Exit(0)
11901190
}
11911191
fmt.Fprintln(f.Output(), err)
@@ -1214,7 +1214,7 @@ func (f *FlagSet) ParseAll(arguments []string, fn func(flag *Flag, value string)
12141214
case ContinueOnError:
12151215
return err
12161216
case ExitOnError:
1217-
if errors.Is(err, ErrHelp) {
1217+
if err == ErrHelp {
12181218
os.Exit(0)
12191219
}
12201220
fmt.Fprintln(f.Output(), err)

0 commit comments

Comments
 (0)