From: Benoit Sigoure Date: Sat, 6 Feb 2016 01:18:46 +0000 (-0800) Subject: cmd/gofmt: Ignore file not found errors. X-Git-Tag: go1.7beta1~1841 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=3ddfaa5653cfc5c8663319d017a5fb4de97814f4;p=gostls13.git cmd/gofmt: Ignore file not found errors. 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 --- diff --git a/src/cmd/gofmt/gofmt.go b/src/cmd/gofmt/gofmt.go index cfebeffe4a..b10b804fd2 100644 --- a/src/cmd/gofmt/gofmt.go +++ b/src/cmd/gofmt/gofmt.go @@ -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