From 3eb0e01bf8fd609d627dea33095625cbcc202329 Mon Sep 17 00:00:00 2001 From: luoxin Date: Thu, 2 Jan 2025 17:08:44 +0800 Subject: [PATCH] =?UTF-8?q?fixed:=20=E7=B1=BB=E5=9E=8B=E5=92=8C=E5=8C=85?= =?UTF-8?q?=E7=9A=84=E8=A7=A3=E6=9E=90=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- codegen/pbparse.go | 9 +++------ codegen/template/client.call.gtpl | 4 ++-- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/codegen/pbparse.go b/codegen/pbparse.go index 1d20544..45208cd 100644 --- a/codegen/pbparse.go +++ b/codegen/pbparse.go @@ -328,24 +328,21 @@ func (p *PbRPC) walk() { } if idx := strings.LastIndex(text, "."); idx > 0 { p.requestPackage = text[idx+1:] - } else { - p.requestPackage = text + text = text[:idx] } } if strings.Contains(p.rpc.ReturnsType, ".") { text := p.rpc.ReturnsType if idx := strings.LastIndex(text, "."); idx > 0 { - p.responsePackage = text[idx+1:] + p.returnsType = text[idx+1:] text = text[:idx] } if idx := strings.LastIndex(text, "."); idx > 0 { p.responsePackage = text[idx+1:] - } else { - p.responsePackage = text + text = text[:idx] } } - } func NewPbRPC(rpc *proto.RPC) *PbRPC { diff --git a/codegen/template/client.call.gtpl b/codegen/template/client.call.gtpl index ec1a72c..8660cff 100644 --- a/codegen/template/client.call.gtpl +++ b/codegen/template/client.call.gtpl @@ -1,5 +1,5 @@ -func {{ .RPC.RpcName }}(ctx *lrpc.Ctx, req *{{ .RequestType }}) (*{{ .ResponseType }}, error) { - var rsp {{ .ResponseType }} +func {{ .RPC.RpcName }}(ctx *lrpc.Ctx, req *{{ .RequestPackage }}.{{ .RequestType }}) (*{{ .ResponsePackage }}.{{ .ResponseType }}, error) { + var rsp {{ .ResponsePackage }}.{{ .ResponseType }} return &rsp, lrpc.Call(ctx, &core.ServiceDiscoveryClient{ ServiceName: ServerName, ServicePath: RpcPath{{ .RPC.RpcName }},