Skip to content

1.3.0: feat: recusively scan folders [#120] (#124)

Latest

Choose a tag to compare

@joseotoro joseotoro released this 17 Feb 12:05
e671a5d
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)
```