diff --git a/goutil.go b/goutil.go index b436c41..1cfff3c 100644 --- a/goutil.go +++ b/goutil.go @@ -62,6 +62,21 @@ func ListFilesExt(dir string, ext string) []string { return list } +func RecListFilesExt(dir string, ext string) []string { + list := make([]string, 0) + traverse := func(path string, info os.FileInfo, err error) error { + if err != nil { + return err + } + if info.IsDir() { + list = append(list, ListFilesExt(path, ext)...) + } + return nil + } + filepath.Walk(dir, traverse) + return list +} + func PathExists(path string) bool { if _, err := os.Stat(path); os.IsNotExist(err) { return false