mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-05 13:22:26 +08:00
fix: fix IsExist function in fileutil/file.go
This commit is contained in:
@@ -17,7 +17,7 @@ func IsExist(path string) bool {
|
||||
if err == nil {
|
||||
return true
|
||||
}
|
||||
if errors.Is(err, os.ErrExist) {
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
return false
|
||||
}
|
||||
return false
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
)
|
||||
|
||||
func TestIsExist(t *testing.T) {
|
||||
cases := []string{"./", "./a.txt"}
|
||||
expected := []bool{true, false}
|
||||
cases := []string{"./", "./file.go", "./a.txt"}
|
||||
expected := []bool{true, true, false}
|
||||
|
||||
for i := 0; i < len(cases); i++ {
|
||||
res := IsExist(cases[i])
|
||||
|
||||
Reference in New Issue
Block a user