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:
Sina Siadat 2016-08-08 02:04:52 +04:30 committed by Brad Fitzpatrick
parent f373bf1eb9
commit 2287296dbe

View file

@ -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
}