summaryrefslogtreecommitdiff
path: root/src/cmd/gofix/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/gofix/main.go')
-rw-r--r--src/cmd/gofix/main.go30
1 files changed, 8 insertions, 22 deletions
diff --git a/src/cmd/gofix/main.go b/src/cmd/gofix/main.go
index e7e7013c5..e0709fc8b 100644
--- a/src/cmd/gofix/main.go
+++ b/src/cmd/gofix/main.go
@@ -198,31 +198,17 @@ func report(err os.Error) {
}
func walkDir(path string) {
- v := make(fileVisitor)
- go func() {
- filepath.Walk(path, v, v)
- close(v)
- }()
- for err := range v {
- if err != nil {
- report(err)
- }
- }
-}
-
-type fileVisitor chan os.Error
-
-func (v fileVisitor) VisitDir(path string, f *os.FileInfo) bool {
- return true
+ filepath.Walk(path, visitFile)
}
-func (v fileVisitor) VisitFile(path string, f *os.FileInfo) {
- if isGoFile(f) {
- v <- nil // synchronize error handler
- if err := processFile(path, false); err != nil {
- v <- err
- }
+func visitFile(path string, f *os.FileInfo, err os.Error) os.Error {
+ if err == nil && isGoFile(f) {
+ err = processFile(path, false)
+ }
+ if err != nil {
+ report(err)
}
+ return nil
}
func isGoFile(f *os.FileInfo) bool {