Skip to content

Commit ccacbd1

Browse files
authored
common: simplify FileExist helper (#32969)
1 parent 5dd0fe2 commit ccacbd1

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

common/path.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,16 @@
1717
package common
1818

1919
import (
20+
"errors"
21+
"io/fs"
2022
"os"
2123
"path/filepath"
2224
)
2325

2426
// FileExist checks if a file exists at filePath.
2527
func FileExist(filePath string) bool {
2628
_, err := os.Stat(filePath)
27-
if err != nil && os.IsNotExist(err) {
28-
return false
29-
}
30-
return true
29+
return !errors.Is(err, fs.ErrNotExist)
3130
}
3231

3332
// AbsolutePath returns datadir + filename, or filename if it is absolute.

0 commit comments

Comments
 (0)