mirror of
https://github.com/golang/go
synced 2024-09-05 07:54:46 +00:00
os: add example for IsNotExist
Show usage of os.IsNotExist in an example. Change-Id: I5306ea06c370099de5b02668dfa02b87b0c2beac Reviewed-on: https://go-review.googlesource.com/25571 Reviewed-by: Russ Cox <rsc@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
f373bf1eb9
commit
2287296dbe
|
@ -52,3 +52,12 @@ func ExampleFileMode() {
|
|||
fmt.Println("named pipe")
|
||||
}
|
||||
}
|
||||
|
||||
func ExampleIsNotExist() {
|
||||
filename := "a-nonexistent-file"
|
||||
if _, err := os.Stat(filename); os.IsNotExist(err) {
|
||||
fmt.Printf("file does not exist")
|
||||
}
|
||||
// Output:
|
||||
// file does not exist
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue