]> Cypherpunks repositories - gostls13.git/commitdiff
os: change example to avoid deprecated function
authorEli Bendersky <eliben@golang.org>
Tue, 29 Jun 2021 23:31:18 +0000 (16:31 -0700)
committerIan Lance Taylor <iant@golang.org>
Wed, 30 Jun 2021 16:44:19 +0000 (16:44 +0000)
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>
src/os/example_test.go

index 3adce517848aab915dee423a3edb9915077a1397..e8554b0b122e750ed5ada1c32045c339e4ce48e7 100644 (file)
@@ -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: