From 91906280c25cc0376eba642b9de1495d4d6b57c9 Mon Sep 17 00:00:00 2001 From: roadwy Date: Thu, 19 Dec 2024 23:01:11 +0800 Subject: [PATCH] fix:fix crash when os.Stat err(j is a symbolic link,but the file not exists) --- pkg/utils/files.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/utils/files.go b/pkg/utils/files.go index e43bd89..88f1c89 100644 --- a/pkg/utils/files.go +++ b/pkg/utils/files.go @@ -90,6 +90,9 @@ func GetAllFilesFromDir(dirName string, recursive bool) []string { fileList, _ = filepath.Glob(fmt.Sprintf("%s/*", dirName)) for _, j := range fileList { dirInfo, _ := os.Stat(j) + if dirInfo == nil { + continue + } if j != "." && !dirInfo.IsDir() && CheckIfElf(j) { results = append(results, j) }