Commit 2287296d authored by Sina Siadat's avatar Sina Siadat Committed by Brad Fitzpatrick

os: add example for IsNotExist

Show usage of os.IsNotExist in an example.

Change-Id: I5306ea06c370099de5b02668dfa02b87b0c2beac
Reviewed-on: https://go-review.googlesource.com/25571Reviewed-by: default avatarRuss Cox <rsc@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent f373bf1e
......@@ -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
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment