You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit was created on GitHub.com and signed with GitHub’s verified signature.
This PR refactors NewFileDirReader to use Go’s standard filepath.WalkDir (here) for directory traversal, and avoid custom recursive implementations. The function efficiently reads all files under a directory, optionally traversing subdirectories up to a configurable maxDepth. Traversal is stopped immediately for directories beyond the allowed depth or when recursion is disabled using fs.SkipDir, avoiding unnecessary filesystem reads and reducing resource usage. This approach is safe, efficient, and reduces the risk of errors compared to manual recursion, while remaining idiomatic and easy to maintain.
Usage:
```
vt scan file YOUR_DIRECTORY (default recursive disabled + maxDepth == 1)
vt scan file YOUR_DIRECTORY -r (recursive enabled with default maxDepth == 1)
vt scan file YOUR_DIRECTORY -r -d 3 (recursive enabled + setting up maxDepth to read more subtrees until reaching depth == 3 on each subdirectory)
```