Skip to content

Commit 0fa3265

Browse files
elibenianlancetaylor
authored andcommitted
os: change example to avoid deprecated function
The IsNotExist function is deprecated; change package example to avoid it and use the recommended way instead. Fixes #46976 Change-Id: I3c301d0a89b6bda42184df314ba8418062ca39ee Reviewed-on: https://go-review.googlesource.com/c/go/+/331692 Trust: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
1 parent d19a533 commit 0fa3265

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/os/example_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package os_test
66

77
import (
8+
"errors"
89
"fmt"
910
"io/fs"
1011
"log"
@@ -71,9 +72,9 @@ func ExampleFileMode() {
7172
}
7273
}
7374

74-
func ExampleIsNotExist() {
75+
func ExampleErrNotExist() {
7576
filename := "a-nonexistent-file"
76-
if _, err := os.Stat(filename); os.IsNotExist(err) {
77+
if _, err := os.Stat(filename); errors.Is(err, fs.ErrNotExist) {
7778
fmt.Println("file does not exist")
7879
}
7980
// Output:

0 commit comments

Comments
 (0)