diff options
author | Russ Cox <rsc@golang.org> | 2020-11-04 18:20:17 -0500 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2020-12-02 16:33:57 +0000 |
commit | c32140fa94cfc51a2152855825f57e27ae3ba133 (patch) | |
tree | b9777c7aff45d975f55b3987dfa440580bbb8f58 /src/cmd/fix | |
parent | 0433845ad18a355413033bb3495ba3195f4c69ec (diff) | |
download | go-c32140fa94cfc51a2152855825f57e27ae3ba133.tar.gz go-c32140fa94cfc51a2152855825f57e27ae3ba133.zip |
all: update to use filepath.WalkDir instead of filepath.Walk
Now that filepath.WalkDir is available, it is more efficient
and should be used in place of filepath.Walk.
Update the tree to reflect best practices.
As usual, the code compiled with Go 1.4 during bootstrap is excluded.
(In this CL, that's only cmd/dist.)
For #42027.
Change-Id: Ib0f7b1e43e50b789052f9835a63ced701d8c411c
Reviewed-on: https://go-review.googlesource.com/c/go/+/267719
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Diffstat (limited to 'src/cmd/fix')
-rw-r--r-- | src/cmd/fix/main.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/cmd/fix/main.go b/src/cmd/fix/main.go index 1cea9a876a..1cedf992cf 100644 --- a/src/cmd/fix/main.go +++ b/src/cmd/fix/main.go @@ -234,10 +234,10 @@ func report(err error) { } func walkDir(path string) { - filepath.Walk(path, visitFile) + filepath.WalkDir(path, visitFile) } -func visitFile(path string, f fs.FileInfo, err error) error { +func visitFile(path string, f fs.DirEntry, err error) error { if err == nil && isGoFile(f) { err = processFile(path, false) } @@ -247,7 +247,7 @@ func visitFile(path string, f fs.FileInfo, err error) error { return nil } -func isGoFile(f fs.FileInfo) bool { +func isGoFile(f fs.DirEntry) bool { // ignore non-Go files name := f.Name() return !f.IsDir() && !strings.HasPrefix(name, ".") && strings.HasSuffix(name, ".go") |