27 lines
483 B
Go
27 lines
483 B
Go
package main
|
|
|
|
import (
|
|
"io/fs"
|
|
"path"
|
|
"path/filepath"
|
|
"strings"
|
|
)
|
|
|
|
func listFilesRecursively(findPath string, hide_hidden bool) (filelist []string, err error) {
|
|
err = filepath.Walk(findPath, func(currentPath string, info fs.FileInfo, err error) error {
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if !info.IsDir() {
|
|
if hide_hidden && strings.HasPrefix(path.Base(currentPath), ".") {
|
|
return nil
|
|
}
|
|
|
|
filelist = append(filelist, currentPath)
|
|
}
|
|
return nil
|
|
})
|
|
|
|
return
|
|
}
|