reset link goctl (#1232)
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user