Explorar o código

更新GetAllFilePath

ila %!s(int64=4) %!d(string=hai) anos
pai
achega
530dcb2011
Modificáronse 1 ficheiros con 3 adicións e 2 borrados
  1. 3 2
      core/file.go

+ 3 - 2
core/file.go

@@ -9,7 +9,7 @@ import (
 )
 
 // GetAllFilePath 获取指定目录内的文件和子目录的文件,递归获取
-func GetAllFilePath(filePaths []string, currentPath string) (excelPaths []string, err error) {
+func GetAllFilePath(filePaths []string, currentPath string) ([]string, error) {
 	//2021-12-23
 	files, err := ioutil.ReadDir(currentPath)
 
@@ -19,7 +19,8 @@ func GetAllFilePath(filePaths []string, currentPath string) (excelPaths []string
 	}
 	for _, f := range files {
 		if f.IsDir() {
-			return GetAllFilePath(filePaths, filepath.Join(currentPath, f.Name()))
+			ret, _ := GetAllFilePath(filePaths, filepath.Join(currentPath, f.Name()))
+			filePaths = append(filePaths, ret...)
 		} else {
 			filePaths = append(filePaths, filepath.Join(currentPath, f.Name()))
 		}