reset link goctl (#1232)

This commit is contained in:
anqiansong
2021-11-13 18:39:07 +08:00
committed by GitHub
parent 57d2f22c24
commit 0cb86c6990
7 changed files with 40 additions and 93 deletions

View File

@@ -1,11 +1,9 @@
package generator
import (
"fmt"
"runtime"
"os/exec"
"github.com/tal-tech/go-zero/tools/goctl/util/console"
"github.com/tal-tech/go-zero/tools/goctl/util/env"
)
// DefaultGenerator defines the environment needs of rpc service generation
@@ -27,24 +25,17 @@ func NewDefaultGenerator() Generator {
// Prepare provides environment detection generated by rpc service,
// including go environment, protoc, whether protoc-gen-go is installed or not
func (g *DefaultGenerator) Prepare() error {
if !env.CanExec() {
return fmt.Errorf("%s: can not start new processes using os.StartProcess or exec.Command", runtime.GOOS)
}
if _, err := env.LookUpGo(); err != nil {
_, err := exec.LookPath("go")
if err != nil {
return err
}
if _, err := env.LookUpProtoc(); err != nil {
_, err = exec.LookPath("protoc")
if err != nil {
return err
}
_, err := env.LookUpProtocGenGoctl()
if err == nil {
return nil
}
_, err = exec.LookPath("protoc-gen-go")
g.log.Warning("%+v", err)
_, err = env.LookUpProtocGenGo()
return err
}