package main
import (
"fmt"
"os"
"path/filepath"
)
func main() {
var files []string
root := "/some/folder/to/scan"
err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
files = append(files, path)
return nil
})
if err != nil {
panic(err)
}
for _, file := range files {
fmt.Println(file)
}
}
if !info.IsDir() {
fileLen := len(info.Name())
if info.Name()[fileLen - 4:] == ".csv" || info.Name()[fileLen - 4:] == ".txt" {
files = append(files, path)
}
}