Files returns the collection of all file paths under the specified path
(folder string)
| 61 | |
| 62 | // Files returns the collection of all file paths under the specified path |
| 63 | func Files(folder string) ([]string, error) { |
| 64 | var result []string |
| 65 | |
| 66 | filepath.Walk(folder, func(filePath string, fi os.FileInfo, err error) error { |
| 67 | if err != nil { |
| 68 | return err |
| 69 | } |
| 70 | if !fi.IsDir() { |
| 71 | // If you want to ignore this directory, return filepath.SkipDir, ie: |
| 72 | // return filepath.SkipDir |
| 73 | result = append(result, filePath) |
| 74 | } |
| 75 | |
| 76 | return nil |
| 77 | }) |
| 78 | |
| 79 | return result, nil |
| 80 | } |
| 81 | |
| 82 | // Md5 get the md5 value of the file based on the path |
| 83 | func Md5(filepath string) (string, error) { |