cwalk
cwalk copied to clipboard
`filepath.SkipDir` is meant to be proactive
Expected: returning filepath.SkipDir
will tell cwalk
that I do not want to walk the directory that it just gave me.
Actual: returning filepath.SkipDir
skips the remainder of the current directory being walked.
one can reproduce by using the following directory structure:
root
|- private
| |- passwords.txt
|- readthis.txt
with the following WalkFn:
func walk(fpath string, info os.FileInfo, err error) error {
if info.IsDir() && info.Name() == "private" {
return filepath.SkipDir
}
fmt.Println(fpath)
}
Assuming that private
gets passed into walk
before readthis.txt
, readthis.txt
will be skipped. Instead what should happen (to be consistent with filepath.Walk
) is that private
should not be walked into, but readthis.txt
should still be walked.