support api templates

This commit is contained in:
kevin
2020-10-15 16:36:49 +08:00
parent 8291eabc2c
commit f904710811
32 changed files with 274 additions and 155 deletions

View File

@@ -6,6 +6,7 @@ import (
"strings"
"github.com/tal-tech/go-zero/tools/goctl/rpc/parser"
"github.com/tal-tech/go-zero/tools/goctl/templatex"
"github.com/tal-tech/go-zero/tools/goctl/util"
)
@@ -58,8 +59,8 @@ func (g *defaultRpcGenerator) genMain() error {
configImport := fmt.Sprintf(`"%v"`, g.mustGetPackage(dirConfig))
imports = append(imports, configImport, pbImport, remoteImport, svcImport)
srv, registers := g.genServer(pkg, file.Service)
head := util.GetHead(g.Ctx.ProtoSource)
return util.With("main").GoFmt(true).Parse(mainTemplate).SaveTo(map[string]interface{}{
head := templatex.GetHead(g.Ctx.ProtoSource)
return templatex.With("main").GoFmt(true).Parse(mainTemplate).SaveTo(map[string]interface{}{
"head": head,
"package": pkg,
"serviceName": g.Ctx.ServiceName.Lower(),