Explorar el Código

更新GetAllFilePath

ila hace 4 años
padre
commit
530dcb2011
Se han modificado 1 ficheros con 3 adiciones y 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()))
 		}