Create a symbol link file named protoc-gen-goctl from goctl (#1076)

This commit is contained in:
anqiansong
2021-09-21 23:13:31 +08:00
committed by GitHub
parent 06e114e5a3
commit e8a340c1c0
10 changed files with 135 additions and 83 deletions

View File

@@ -4,22 +4,17 @@ import (
"errors"
"fmt"
"path/filepath"
"runtime"
"github.com/urfave/cli"
"github.com/tal-tech/go-zero/tools/goctl/rpc/generator"
"github.com/tal-tech/go-zero/tools/goctl/util"
"github.com/tal-tech/go-zero/tools/goctl/util/env"
"github.com/urfave/cli"
)
// RPC is to generate rpc service code from a proto file by specifying a proto file using flag src,
// you can specify a target folder for code generation, when the proto file has import, you can specify
// the import search directory through the proto_path command, for specific usage, please refer to protoc -h
func RPC(c *cli.Context) error {
if err := prepare(); err != nil {
return err
}
src := c.String("src")
out := c.String("dir")
style := c.String("style")
@@ -47,22 +42,6 @@ func RPC(c *cli.Context) error {
return g.Generate(src, out, protoImportPath, goOptions...)
}
func 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 {
return err
}
if _, err := env.LookUpProtoc(); err != nil {
return err
}
if _, err := env.LookUpProtocGenGo(); err != nil {
return err
}
return nil
}
// RPCNew is to generate rpc greet service, this greet service can speed
// up your understanding of the zrpc service structure
func RPCNew(c *cli.Context) error {