25 lines
518 B
Go
25 lines
518 B
Go
package commons
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
"path/filepath"
|
|
)
|
|
|
|
// FileDeepScan will scan dir recursively and append any files found to files.
|
|
func FileDeepScan(dir string, files *[]string) {
|
|
entries, err := os.ReadDir(dir)
|
|
if err != nil {
|
|
log.Printf("Failed to read %v", err)
|
|
return
|
|
}
|
|
|
|
for _, entry := range entries {
|
|
fullPath := filepath.Join(dir, entry.Name())
|
|
if entry.IsDir() {
|
|
FileDeepScan(fullPath, files)
|
|
} else {
|
|
*files = append(*files, filepath.Join(dir, entry.Name()))
|
|
}
|
|
}
|
|
} |