Skip to content

Commit

Permalink
UTILS: Add ScanFilesInDir() method which will scan for files in a dir…
Browse files Browse the repository at this point in the history
…ectory.
  • Loading branch information
Cian911 committed Dec 28, 2021
1 parent 5f9b377 commit de4b56c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,18 @@ func ValidateFileExt(ext string) bool {
return true
}

func ScanFilesInDir(path string) (map[string]string, error) {
func ScanFilesInDir(path string) (map[string]bool, error) {
files, err := ioutil.ReadDir(path)
if err != nil {
return nil, err
}

fileList := map[string]string{}
/* for _, file := range files { */
/* */
/* } */
// "sample.txt" -> false
// "folder1" -> true
fileList := make(map[string]bool)
for _, file := range files {
fileList[file.Name()] = file.IsDir()
}

return fileList, nil
}

0 comments on commit de4b56c

Please sign in to comment.