Commit 35cee9f5 authored by Russ Cox's avatar Russ Cox

gofmt: simpler walkDir

Swapping the goroutines lets them reuse the
communication completion on v instead of
needing a second channel (done).

R=gri
CC=golang-dev
https://golang.org/cl/4287045
parent 108564da
...@@ -158,21 +158,16 @@ func (v fileVisitor) VisitFile(path string, f *os.FileInfo) { ...@@ -158,21 +158,16 @@ func (v fileVisitor) VisitFile(path string, f *os.FileInfo) {
func walkDir(path string) { func walkDir(path string) {
// start an error handler
done := make(chan bool)
v := make(fileVisitor) v := make(fileVisitor)
go func() { go func() {
filepath.Walk(path, v, v)
close(v)
}()
for err := range v { for err := range v {
if err != nil { if err != nil {
report(err) report(err)
} }
} }
done <- true
}()
// walk the tree
filepath.Walk(path, v, v)
close(v) // terminate error handler loop
<-done // wait for all errors to be reported
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment