]> Cypherpunks repositories - gostls13.git/commitdiff
os: add example for IsNotExist
authorSina Siadat <siadat@gmail.com>
Sun, 7 Aug 2016 21:34:52 +0000 (02:04 +0430)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 12 Oct 2016 08:03:00 +0000 (08:03 +0000)
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>

src/os/example_test.go

index a28255254b4cde0dae6762e5ce30c1e7820b58db..9c890c451973cee8b65e0f3194f58bdea1e701e9 100644 (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
+}