1 Star 0 Fork 0

Souki/go-framework

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
path.go 809 Bytes
一键复制 编辑 原始数据 按行查看 历史
Souki 提交于 2021-11-03 10:51 +08:00 . !20新增 catchRecover方法
package utils
import (
"os"
"path/filepath"
"strings"
)
//运行的程序所在目录
func BasePath() string {
executer, err := os.Executable()
if err != nil {
panic("Cannot get executable folder, just panic: " + err.Error())
}
basePath := filepath.Dir(executer)
return basePath
}
// 当前目录(与运行程序所在目录无关)
func CurrentPath() string {
basePath, err := filepath.Abs("./")
if err != nil {
panic(err)
}
return basePath
}
//获取文件后缀
func FileExt(file string) string {
arr := strings.Split(file, ".")
return arr[len(arr)-1]
}
//文件或目录是否存在
func IsExistPath(path string) bool {
_, err := os.Stat(path)
if err != nil {
if os.IsExist(err) {
return true
}
if os.IsNotExist(err) {
return false
}
return false
}
return true
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/scottq/go-framework.git
git@gitee.com:scottq/go-framework.git
scottq
go-framework
go-framework
v1.1.21

搜索帮助