//==========================================
//创建时间:2017-4-20 首次创建
//功能描述:windows和Linux下路径兼容处理
//==========================================
package env
import (
"os"
"runtime"
)
var ostype = runtime.GOOS
func GetProjectPath() string{
var projectPath string
projectPath, _ = os.Getwd()
return projectPath
}
func GetConfigPath() string{
path := GetProjectPath()
if ostype == "windows"{
path = path + "\\" + "config\\"
}else if ostype == "linux"{
path = path +"/" + "config/"
}
return path
}
func GetConLogPath() string{
path := GetProjectPath()
if ostype == "windows"{
path = path + "\\log\\"
}else if ostype == "linux"{
path = path + "/log/"
}
return path
}
本文介绍了一个用于处理Windows和Linux系统中文件路径的Go语言程序。该程序定义了几个函数,用于获取项目的根目录、配置文件目录及日志文件目录,并确保这些路径在不同操作系统上能够正确解析。
433

被折叠的 条评论
为什么被折叠?



