Use filepath.WalkDir instead of filepath.Walk for better performance and modern io/fs integration. WalkDir avoids calling os.Lstat on every entry by using fs.DirEntry, which is significantly faster for large directory trees.
err := filepath.WalkDir("./path", func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
if d.IsDir() {
return nil
}
// Process file
return nil
})