|
|
@ -5,18 +5,19 @@ import (
|
|
|
|
"os/exec"
|
|
|
|
"os/exec"
|
|
|
|
"runtime"
|
|
|
|
"runtime"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/zeromicro/go-zero/tools/goctl/util/env"
|
|
|
|
"github.com/zeromicro/go-zero/tools/goctl/vars"
|
|
|
|
"github.com/zeromicro/go-zero/tools/goctl/vars"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const goproxy = "GOPROXY=https://goproxy.cn,direct"
|
|
|
|
|
|
|
|
|
|
|
|
func goStart(dir string) {
|
|
|
|
func goStart(dir string) {
|
|
|
|
goproxy := "GOPROXY=https://goproxy.cn"
|
|
|
|
execCommand(dir, "go run .", prepareGoProxyEnv()...)
|
|
|
|
execCommand(dir, "go run .", goproxy)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func goModTidy(dir string) int {
|
|
|
|
func goModTidy(dir string) int {
|
|
|
|
goproxy := "GOPROXY=https://goproxy.cn"
|
|
|
|
|
|
|
|
log.Debug(">> go mod tidy")
|
|
|
|
log.Debug(">> go mod tidy")
|
|
|
|
return execCommand(dir, "go mod tidy", goproxy)
|
|
|
|
return execCommand(dir, "go mod tidy", prepareGoProxyEnv()...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func execCommand(dir string, arg string, envArgs ...string) int {
|
|
|
|
func execCommand(dir string, arg string, envArgs ...string) int {
|
|
|
@ -33,3 +34,11 @@ func execCommand(dir string, arg string, envArgs ...string) int {
|
|
|
|
_ = cmd.Run()
|
|
|
|
_ = cmd.Run()
|
|
|
|
return cmd.ProcessState.ExitCode()
|
|
|
|
return cmd.ProcessState.ExitCode()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func prepareGoProxyEnv(envArgs ...string) []string {
|
|
|
|
|
|
|
|
if env.InChina() {
|
|
|
|
|
|
|
|
return append(envArgs, goproxy)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return envArgs
|
|
|
|
|
|
|
|
}
|
|
|
|