How to reproduce:
$ mkdir /tmp/foo
$ cp /dev/null /tmp/foo/bar.go
$ chmod -r /tmp/foo/bar.go
$ gofmt /tmp/foo
open /tmp/foo/bar.go: permission denied
$ echo $? # should echo 2
0
$
Maybe you need to put a call to time.Sleep at the beginning of report().
R=gri
CC=golang-dev
https://golang.org/cl/164073
func walkDir(path string) {
// start an error handler
+ done := make(chan bool);
v := make(fileVisitor);
go func() {
for err := range v {
report(err)
}
}
+ done <- true;
}();
// walk the tree
pathutil.Walk(path, v, v);
- close(v);
+ close(v); // terminate error handler loop
+ <-done; // wait for all errors to be reported
}