Skip to content

Commit

Permalink
prevent crash in DirectoryTree when Walk passes an error and nil info
Browse files Browse the repository at this point in the history
  • Loading branch information
elv-gilles committed Oct 3, 2023
1 parent ce6faa5 commit 0ea6502
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions util/filesystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ func PrintDirectoryTree(dir string) {
func DirectoryTree(dir string) string {
var sb strings.Builder
_ = filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
if err != nil {
return nil
}
p, _ := filepath.Rel(dir, path)
indent := strings.Repeat(" ", strings.Count(p, "/"))
ftype := "f"
Expand Down

0 comments on commit 0ea6502

Please sign in to comment.