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>
package os_test
import (
+ "errors"
"fmt"
"io/fs"
"log"
}
}
-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: