]> Cypherpunks repositories - gostls13.git/commitdiff
os: don't check for IsExist in MkdirAll example
authorStefan Dombrowski <sdo451@gmail.com>
Mon, 6 Jun 2022 08:23:37 +0000 (08:23 +0000)
committerGopher Robot <gobot@golang.org>
Wed, 29 Mar 2023 22:44:59 +0000 (22:44 +0000)
If a directory already exists, then MkdirAll returns nil. Therefore the
check with IsExist is not necessary.

Change-Id: Idf83c056f64bb56f49eb2b649af7827b759bcd7c
GitHub-Last-Rev: 1f29873d0cd852642938cbd899549b9bf04301da
GitHub-Pull-Request: golang/go#53242
Reviewed-on: https://go-review.googlesource.com/c/go/+/410434
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/os/example_test.go

index 53e3c5227ba6480192b1379a1b12f0c56f2f673a..5c7c6eac87da1066ae4ab82ad21d7d1e81a3817e 100644 (file)
@@ -255,7 +255,7 @@ func ExampleMkdir() {
 
 func ExampleMkdirAll() {
        err := os.MkdirAll("test/subdir", 0750)
-       if err != nil && !os.IsExist(err) {
+       if err != nil {
                log.Fatal(err)
        }
        err = os.WriteFile("test/subdir/testfile.txt", []byte("Hello, Gophers!"), 0660)