1 Star 0 Fork 0

younland / brick

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
is.go 690 Bytes
一键复制 编辑 原始数据 按行查看 历史
严宇川 提交于 2022-01-06 15:48 . v0.0.1
package xfile
import (
"bufio"
"image"
_ "image/gif" // ...
_ "image/jpeg" // ...
_ "image/png" // ...
"os"
)
// IsExist ...
func IsExist(filepath string) bool {
_, err := os.Stat(filepath)
return err == nil || os.IsExist(err)
}
// IsFile ...
func IsFile(filepath string) bool {
file, err := os.Stat(filepath)
return err == nil && !file.IsDir()
}
// IsDir ...
func IsDir(filepath string) bool {
file, err := os.Stat(filepath)
return err == nil && file.IsDir()
}
// IsImage ...
func IsImage(filepath string) bool {
file, err := os.Open(filepath)
if err != nil {
return false
}
defer file.Close()
_, _, err = image.Decode(bufio.NewReader(file))
return err == nil
}
1
https://gitee.com/younland/brick.git
git@gitee.com:younland/brick.git
younland
brick
brick
v1.0.1

搜索帮助

53164aa7 5694891 3bd8fe86 5694891