diff options
author | Matthew Lemon <lemon@matthewlemon.com> | 2019-12-01 20:43:47 +0000 |
---|---|---|
committer | Matthew Lemon <lemon@matthewlemon.com> | 2019-12-01 21:26:05 +0000 |
commit | 332aee4fa6c75e07337efaa44e2b4c8ec4348c65 (patch) | |
tree | 5af4e3f15a90450b74639a2ab2bb249fbe77bc07 /reader/reader.go | |
parent | 6eabf4b870e298354fa1c6ad6cfd5a47cb6efe07 (diff) |
added test for basic glob of target directory
Diffstat (limited to 'reader/reader.go')
-rw-r--r-- | reader/reader.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/reader/reader.go b/reader/reader.go index 449b8ba..4b9c425 100644 --- a/reader/reader.go +++ b/reader/reader.go @@ -7,6 +7,7 @@ import ( "io" "io/ioutil" "log" + "path/filepath" "strings" "github.com/tealeg/xlsx" @@ -174,3 +175,16 @@ func Extract(dm string, ssheet string) ExtractedData { } return outer } + +//GetTargetFiles finds all xlsx and xlsm files in directory. +func GetTargetFiles(path string) ([]string, error) { + fullpath := strings.Join([]string{path, "*.xlsx"}, "") + output, err := filepath.Glob(fullpath) + if err != nil { + return nil, err + } + if output == nil { + return nil, fmt.Errorf("cannot find any xlsx files in %s\n", path) + } + return output, nil +} |