Skip to content

Commit

Permalink
🏎️ Replace filepath.Walk with more efficient filepath.WalkDir
Browse files Browse the repository at this point in the history
From the Go docs:

> Walk is less efficient than WalkDir, introduced in Go 1.16, which
> avoids calling os.Lstat on every visited file or directory.
  • Loading branch information
jasonrudolph committed Jul 16, 2021
1 parent 62b65b3 commit 4b9a246
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions internal/cmd/submit/submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ func toTar(dir string) (dest string, err error) {
return "", err
}

err = filepath.Walk(dir, func(srcpath string, info os.FileInfo, err error) error {
err = filepath.WalkDir(dir, func(srcpath string, _ os.DirEntry, err error) error {
if err != nil {
return err
}
Expand All @@ -294,7 +294,6 @@ func toTar(dir string) (dest string, err error) {
return err
}

fmt.Println("Writing from/to", srcpath, destpath)
err = t.Write(srcpath, destpath)
if err != nil {
return err
Expand Down

0 comments on commit 4b9a246

Please sign in to comment.