mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-10 02:43:37 +02:00
fix logs not printing correctly, removed unneccessary loggers
This commit is contained in:
@@ -8,13 +8,17 @@ import (
|
||||
|
||||
// Recursively lists all files in a directory until `maxDepth` is reached
|
||||
// Returns a slice of file paths relative to `dir`.
|
||||
func ListFiles(dir string, maxDepth int) ([]string, error) {
|
||||
func ListFiles(dir string, maxDepth int, hideHidden ...bool) ([]string, error) {
|
||||
entries, err := os.ReadDir(dir)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error listing directory %s: %w", dir, err)
|
||||
}
|
||||
hideHiddenFiles := len(hideHidden) > 0 && hideHidden[0]
|
||||
files := make([]string, 0)
|
||||
for _, entry := range entries {
|
||||
if hideHiddenFiles && entry.Name()[0] == '.' {
|
||||
continue
|
||||
}
|
||||
if entry.IsDir() {
|
||||
if maxDepth <= 0 {
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user