Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func getFiles(dirPath string) ([]string, error) {
- // check if dirPath ends with "/"
- if !strings.HasSuffix(dirPath, "/") {
- dirPath += "/"
- }
- files, err := ioutil.ReadDir(dirPath)
- if err != nil {
- return nil, err
- }
- var fileNames []string
- for _, f := range files {
- if f.IsDir() {
- continue
- }
- fileNames = append(fileNames, f.Name())
- }
- return fileNames, nil
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement