#Listing files in directories and subdirectories

3 messages · Page 1 of 1 (latest)

frosty ice
#

I have the following code:

func (f *DirectoryRepositoryImplementation) ListFiles(rootDirectory string, exts []string) ([]string, error) {
    var files []string
    err := filepath.WalkDir(rootDirectory, func(path string, d fs.DirEntry, err error) error {
        if d.IsDir() {
            return nil
        }
        for _, s := range exts {
            if strings.HasSuffix(path, "."+s) {
                files = append(files, path)
                return nil
            }
        }
        return nil
    })
    return files, err
}
``` just want to return all text files in a given dir and its subdirectories, and it just returns an error <nil>
#

i am so stupid

#

ignore