Skip to content

Commit 04235e8

Browse files
committed
Fix the infinite recursion by skipping the current directory in the directory names listing
1 parent ee6eef7 commit 04235e8

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

path.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ func walk(fs Fs, path string, info os.FileInfo, walkFn filepath.WalkFunc) error
5959
}
6060

6161
for _, name := range names {
62+
if name == path {
63+
// skip current directory to avoid infinite recursion
64+
continue
65+
}
6266
filename := filepath.Join(path, name)
6367
fileInfo, err := lstatIfPossible(fs, filename)
6468
if err != nil {

0 commit comments

Comments
 (0)