From 2287296dbe43c5dfa9afebf0e03af42318a6a8f0 Mon Sep 17 00:00:00 2001 From: Sina Siadat Date: Mon, 8 Aug 2016 02:04:52 +0430 Subject: [PATCH] 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 Run-TryBot: Brad Fitzpatrick TryBot-Result: Gobot Gobot --- src/os/example_test.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/os/example_test.go b/src/os/example_test.go index a28255254b..9c890c4519 100644 --- a/src/os/example_test.go +++ b/src/os/example_test.go @@ -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 +} -- 2.48.1