From 75f147a3627d2a52db570eef41b8be9efd238dec Mon Sep 17 00:00:00 2001 From: wit liu <765765346@qq.com> Date: Fri, 19 Dec 2025 15:07:32 +0800 Subject: [PATCH] common: simplify FileExist helper #32969 (#1871) --- common/path.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/common/path.go b/common/path.go index c1e382fd29..b2b07f56ef 100644 --- a/common/path.go +++ b/common/path.go @@ -17,6 +17,8 @@ package common import ( + "errors" + "io/fs" "os" "path/filepath" ) @@ -24,11 +26,7 @@ import ( // FileExist checks if a file exists at filePath. func FileExist(filePath string) bool { _, err := os.Stat(filePath) - if err != nil && os.IsNotExist(err) { - return false - } - - return true + return !errors.Is(err, fs.ErrNotExist) } // AbsolutePath returns datadir + filename, or filename if it is absolute.