mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-24 18:00:24 +08:00
17e6cfb7a9
* 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
23 lines
451 B
Go
23 lines
451 B
Go
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
|
|
}
|