diff --git a/tools/goctl/rpc/generator/gencall.go b/tools/goctl/rpc/generator/gencall.go index cbfad52e..1e97f932 100644 --- a/tools/goctl/rpc/generator/gencall.go +++ b/tools/goctl/rpc/generator/gencall.go @@ -23,7 +23,7 @@ package {{.filePackage}} import ( "context" - + "google.golang.org/grpc" {{.package}} "github.com/tal-tech/go-zero/zrpc" @@ -51,13 +51,13 @@ func New{{.serviceName}}(cli zrpc.Client) {{.serviceName}} { ` callInterfaceFunctionTemplate = `{{if .hasComment}}{{.comment}} -{{end}}{{.method}}(ctx context.Context{{if .hasReq}},in *{{.pbRequest}}{{end}}) ({{if .notStream}}*{{.pbResponse}}, {{else}}{{.streamBody}},{{end}} error)` +{{end}}{{.method}}(ctx context.Context{{if .hasReq}}, in *{{.pbRequest}}{{end}}, opts ...grpc.CallOption) ({{if .notStream}}*{{.pbResponse}}, {{else}}{{.streamBody}},{{end}} error)` callFunctionTemplate = ` {{if .hasComment}}{{.comment}}{{end}} -func (m *default{{.serviceName}}) {{.method}}(ctx context.Context{{if .hasReq}},in *{{.pbRequest}}{{end}}) ({{if .notStream}}*{{.pbResponse}}, {{else}}{{.streamBody}},{{end}} error) { +func (m *default{{.serviceName}}) {{.method}}(ctx context.Context{{if .hasReq}}, in *{{.pbRequest}}{{end}}, opts ...grpc.CallOption) ({{if .notStream}}*{{.pbResponse}}, {{else}}{{.streamBody}},{{end}} error) { client := {{.package}}.New{{.rpcServiceName}}Client(m.cli.Conn()) - return client.{{.method}}(ctx,{{if .hasReq}} in{{end}}) + return client.{{.method}}(ctx{{if .hasReq}}, in{{end}}, opts...) } ` )