diff options
Diffstat (limited to 'src/errors')
| -rw-r--r-- | src/errors/wrap_test.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/errors/wrap_test.go b/src/errors/wrap_test.go index 590c1857e3..4a4a732c9b 100644 --- a/src/errors/wrap_test.go +++ b/src/errors/wrap_test.go @@ -238,6 +238,19 @@ func (errorUncomparable) Is(target error) bool { return ok } +func ExampleIs() { + if _, err := os.Open("non-existing"); err != nil { + if errors.Is(err, os.ErrNotExist) { + fmt.Println("file does not exist") + } else { + fmt.Println(err) + } + } + + // Output: + // file does not exist +} + func ExampleAs() { if _, err := os.Open("non-existing"); err != nil { var pathError *os.PathError |
