From ccacbd1e3777893d4ba9add4c452530e29a3830b Mon Sep 17 00:00:00 2001 From: Coder <161350311+MamunC0der@users.noreply.github.com> Date: Thu, 30 Oct 2025 02:20:07 +0100 Subject: [PATCH] common: simplify FileExist helper (#32969) --- common/path.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/common/path.go b/common/path.go index 19f24d426a..841946348e 100644 --- a/common/path.go +++ b/common/path.go @@ -17,6 +17,8 @@ package common import ( + "errors" + "io/fs" "os" "path/filepath" ) @@ -24,10 +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.