quickly generating rpc demo service (#60)
* add execute files * add protoc-osx * add rpc generation * add rpc generation * add: rpc template generation * add README.md * format error * reactor templatex.go * update project.go & README.md * add: quickly generate rpc service
This commit is contained in:
22
tools/goctl/rpc/gen/gomod.go
Normal file
22
tools/goctl/rpc/gen/gomod.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package gen
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/tal-tech/go-zero/core/logx"
|
||||
"github.com/tal-tech/go-zero/tools/goctl/rpc/execx"
|
||||
)
|
||||
|
||||
func (g *defaultRpcGenerator) initGoMod() error {
|
||||
if !g.Ctx.IsInGoEnv {
|
||||
projectDir := g.dirM[dirTarget]
|
||||
cmd := fmt.Sprintf("go mod init %s", g.Ctx.ProjectName.Source())
|
||||
output, err := execx.Run(fmt.Sprintf(cmd), projectDir)
|
||||
if err != nil {
|
||||
logx.Error(err)
|
||||
return err
|
||||
}
|
||||
g.Ctx.Info(output)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user