]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gofmt: Ignore file not found errors.
authorBenoit Sigoure <tsunanet@gmail.com>
Sat, 6 Feb 2016 01:18:46 +0000 (17:18 -0800)
committerRobert Griesemer <gri@golang.org>
Fri, 19 Feb 2016 00:13:18 +0000 (00:13 +0000)
gofmt prints an error to stderr when a file is deleted during its
`filepath.Walk()', which can happen in builds that change the tree
concurrently with gofmt running.

Change-Id: Ia1aa4804f6bc2172baf061c093e16fe56a3ee50c
Reviewed-on: https://go-review.googlesource.com/19301
Reviewed-by: Robert Griesemer <gri@golang.org>
src/cmd/gofmt/gofmt.go

index cfebeffe4a673575e9d088b5d41836878a0b65d9..b10b804fd2cb23a3675d41f5c3c31138cdfb76cf 100644 (file)
@@ -143,7 +143,9 @@ func visitFile(path string, f os.FileInfo, err error) error {
        if err == nil && isGoFile(f) {
                err = processFile(path, nil, os.Stdout, false)
        }
-       if err != nil {
+       // Don't complain if a file was deleted in the meantime (i.e.
+       // the directory changed concurrently while running gofmt).
+       if err != nil && !os.IsNotExist(err) {
                report(err)
        }
        return nil