golang实现兼容Linux和Windows的路径处理

来源:互联网 发布:天一混元青岛店淘宝 编辑:程序博客网 时间:2024/06/06 02:15

//==========================================
//创建时间:2017-4-20 首次创建
//功能描述:windows和Linux下路径兼容处理
//==========================================

package envimport (    "os"    "runtime")var ostype = runtime.GOOSfunc 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}
0 0
原创粉丝点击