Dirs returns a slice of all the directories within a given directory
(path string)
| 10 | |
| 11 | // Dirs returns a slice of all the directories within a given directory |
| 12 | func Dirs(path string) []string { |
| 13 | files, err := os.ReadDir(path) |
| 14 | if err != nil { |
| 15 | return nil |
| 16 | } |
| 17 | |
| 18 | var fnms []string |
| 19 | for _, fi := range files { |
| 20 | if fi.IsDir() { |
| 21 | fnms = append(fnms, fi.Name()) |
| 22 | } |
| 23 | } |
| 24 | return fnms |
| 25 | } |