From: Eli Bendersky Date: Tue, 29 Jun 2021 23:31:18 +0000 (-0700) Subject: os: change example to avoid deprecated function X-Git-Tag: go1.17rc1~28 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=0fa3265fe14c775668fc8272f47adf4fbaa60bac;p=gostls13.git 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 Reviewed-by: Ian Lance Taylor Reviewed-by: Robert Griesemer --- diff --git a/src/os/example_test.go b/src/os/example_test.go index 3adce51784..e8554b0b12 100644 --- a/src/os/example_test.go +++ b/src/os/example_test.go @@ -5,6 +5,7 @@ package os_test import ( + "errors" "fmt" "io/fs" "log" @@ -71,9 +72,9 @@ func ExampleFileMode() { } } -func ExampleIsNotExist() { +func ExampleErrNotExist() { filename := "a-nonexistent-file" - if _, err := os.Stat(filename); os.IsNotExist(err) { + if _, err := os.Stat(filename); errors.Is(err, fs.ErrNotExist) { fmt.Println("file does not exist") } // Output: