You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-fly/tools/file.go

30 lines
548 B

package tools
import "os"
//判断文件文件夹是否存在(字节0也算不存在)
func IsFileExist(path string) (bool, error) {
fileInfo, err := os.Stat(path)
if os.IsNotExist(err) {
return false, nil
}
//我这里判断了如果是0也算不存在
if fileInfo.Size() == 0 {
return false, nil
}
if err == nil {
return true, nil
}
return false, err
}
//判断文件文件夹不存在
func IsFileNotExist(path string) (bool, error) {
_, err := os.Stat(path)
if os.IsNotExist(err) {
return true, nil
}
return false, err
}