|
@@ -7,7 +7,6 @@ import (
|
|
|
|
|
|
"github.com/tal-tech/go-zero/core/collection"
|
|
"github.com/tal-tech/go-zero/core/collection"
|
|
"github.com/tal-tech/go-zero/tools/goctl/rpc/parser"
|
|
"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"
|
|
"github.com/tal-tech/go-zero/tools/goctl/util"
|
|
)
|
|
)
|
|
|
|
|
|
@@ -123,8 +122,8 @@ func (g *defaultRpcGenerator) genCall() error {
|
|
}
|
|
}
|
|
|
|
|
|
filename := filepath.Join(callPath, typesFilename)
|
|
filename := filepath.Join(callPath, typesFilename)
|
|
- head := templatex.GetHead(g.Ctx.ProtoSource)
|
|
|
|
- err = templatex.With("types").GoFmt(true).Parse(callTemplateTypes).SaveTo(map[string]interface{}{
|
|
|
|
|
|
+ head := util.GetHead(g.Ctx.ProtoSource)
|
|
|
|
+ err = util.With("types").GoFmt(true).Parse(callTemplateTypes).SaveTo(map[string]interface{}{
|
|
"head": head,
|
|
"head": head,
|
|
"const": constLit,
|
|
"const": constLit,
|
|
"filePackage": service.Name.Lower(),
|
|
"filePackage": service.Name.Lower(),
|
|
@@ -147,7 +146,7 @@ func (g *defaultRpcGenerator) genCall() error {
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
|
|
|
|
- err = templatex.With("shared").GoFmt(true).Parse(callTemplateText).SaveTo(map[string]interface{}{
|
|
|
|
|
|
+ err = util.With("shared").GoFmt(true).Parse(callTemplateText).SaveTo(map[string]interface{}{
|
|
"name": service.Name.Lower(),
|
|
"name": service.Name.Lower(),
|
|
"head": head,
|
|
"head": head,
|
|
"filePackage": service.Name.Lower(),
|
|
"filePackage": service.Name.Lower(),
|
|
@@ -167,7 +166,7 @@ func (g *defaultRpcGenerator) genFunction(service *parser.RpcService) ([]string,
|
|
imports.AddStr(fmt.Sprintf(`%v "%v"`, pkgName, g.mustGetPackage(dirPb)))
|
|
imports.AddStr(fmt.Sprintf(`%v "%v"`, pkgName, g.mustGetPackage(dirPb)))
|
|
for _, method := range service.Funcs {
|
|
for _, method := range service.Funcs {
|
|
imports.AddStr(g.ast.Imports[method.ParameterIn.Package])
|
|
imports.AddStr(g.ast.Imports[method.ParameterIn.Package])
|
|
- buffer, err := templatex.With("sharedFn").Parse(callFunctionTemplate).Execute(map[string]interface{}{
|
|
|
|
|
|
+ buffer, err := util.With("sharedFn").Parse(callFunctionTemplate).Execute(map[string]interface{}{
|
|
"rpcServiceName": service.Name.Title(),
|
|
"rpcServiceName": service.Name.Title(),
|
|
"method": method.Name.Title(),
|
|
"method": method.Name.Title(),
|
|
"package": pkgName,
|
|
"package": pkgName,
|
|
@@ -190,7 +189,7 @@ func (g *defaultRpcGenerator) getInterfaceFuncs(service *parser.RpcService) ([]s
|
|
functions := make([]string, 0)
|
|
functions := make([]string, 0)
|
|
|
|
|
|
for _, method := range service.Funcs {
|
|
for _, method := range service.Funcs {
|
|
- buffer, err := templatex.With("interfaceFn").Parse(callInterfaceFunctionTemplate).Execute(
|
|
|
|
|
|
+ buffer, err := util.With("interfaceFn").Parse(callInterfaceFunctionTemplate).Execute(
|
|
map[string]interface{}{
|
|
map[string]interface{}{
|
|
"hasComment": method.HaveDoc(),
|
|
"hasComment": method.HaveDoc(),
|
|
"comment": method.GetDoc(),
|
|
"comment": method.GetDoc(),
|