Fix the infinite recursion by skipping the current directory in the directory names listing

This commit is contained in:
erstam 2023-11-14 12:22:35 -05:00
parent 5c4385aa20
commit c689108954
1 changed files with 4 additions and 0 deletions

View File

@ -59,6 +59,10 @@ func walk(fs Fs, path string, info os.FileInfo, walkFn filepath.WalkFunc) error
}
for _, name := range names {
if name == path {
// skip current directory to avoid infinite recursion
continue
}
filename := filepath.Join(path, name)
fileInfo, err := lstatIfPossible(fs, filename)
if err != nil {