1 Star 0 Fork 0

api-go/revel-cmd

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
command.go 737 Bytes
一键复制 编辑 原始数据 按行查看 历史
package utils
import (
"go/build"
"os"
"os/exec"
"strings"
)
// Initialize the command based on the GO environment
func CmdInit(c *exec.Cmd, basePath string) {
c.Dir = basePath
// Go 1.8 fails if we do not include the GOROOT
c.Env = []string{"GOPATH=" + build.Default.GOPATH, "PATH=" + GetEnv("PATH"), "GOROOT="+ GetEnv("GOROOT")}
// Fetch the rest of the env variables
for _, e := range os.Environ() {
pair := strings.Split(e, "=")
if pair[0]=="GOPATH" {
continue
}
c.Env = append(c.Env,e)
}
}
// Returns an environment variable
func GetEnv(name string) string {
for _, v := range os.Environ() {
split := strings.Split(v, "=")
if split[0] == name {
return strings.Join(split[1:], "")
}
}
return ""
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/netscript/revel-cmd.git
git@gitee.com:netscript/revel-cmd.git
netscript
revel-cmd
revel-cmd
v0.20.2

搜索帮助

0d507c66 1850385 C8b1a773 1850385