From e481b63b210ba7e8be93c7d85f5e9d448fa7ca46 Mon Sep 17 00:00:00 2001 From: neosu <280097765@qq.com> Date: Sun, 18 Jul 2021 22:05:28 +0800 Subject: [PATCH] Fix the error stream method name (#826) --- tools/goctl/rpc/generator/gencall.go | 19 ++----------------- tools/goctl/rpc/generator/genlogic.go | 9 +-------- tools/goctl/rpc/generator/genserver.go | 10 +--------- 3 files changed, 4 insertions(+), 34 deletions(-) diff --git a/tools/goctl/rpc/generator/gencall.go b/tools/goctl/rpc/generator/gencall.go index a2ae50ba..e192b78f 100644 --- a/tools/goctl/rpc/generator/gencall.go +++ b/tools/goctl/rpc/generator/gencall.go @@ -115,14 +115,7 @@ func (g *DefaultGenerator) genFunction(goPackage string, service parser.Service) } comment := parser.GetComment(rpc.Doc()) - var streamServer string - if rpc.StreamsRequest && rpc.StreamsReturns { - streamServer = fmt.Sprintf("%s.%s", goPackage, parser.CamelCase(service.Name)+"_StreamClient") - } else if rpc.StreamsRequest { - streamServer = fmt.Sprintf("%s.%s", goPackage, parser.CamelCase(service.Name)+"_ClientStreamClient") - } else { - streamServer = fmt.Sprintf("%s.%s", goPackage, parser.CamelCase(service.Name)+"_ServerStreamClient") - } + streamServer := fmt.Sprintf("%s.%s_%s%s", goPackage, parser.CamelCase(service.Name), parser.CamelCase(rpc.Name), "Client") buffer, err := util.With("sharedFn").Parse(text).Execute(map[string]interface{}{ "serviceName": stringx.From(service.Name).ToCamel(), "rpcServiceName": parser.CamelCase(service.Name), @@ -155,15 +148,7 @@ func (g *DefaultGenerator) getInterfaceFuncs(goPackage string, service parser.Se } comment := parser.GetComment(rpc.Doc()) - var streamServer string - if rpc.StreamsRequest && rpc.StreamsReturns { - streamServer = fmt.Sprintf("%s.%s", goPackage, parser.CamelCase(service.Name)+"_StreamClient") - } else if rpc.StreamsRequest { - streamServer = fmt.Sprintf("%s.%s", goPackage, parser.CamelCase(service.Name)+"_ClientStreamClient") - } else { - streamServer = fmt.Sprintf("%s.%s", goPackage, parser.CamelCase(service.Name)+"_ServerStreamClient") - } - + streamServer := fmt.Sprintf("%s.%s_%s%s", goPackage, parser.CamelCase(service.Name), parser.CamelCase(rpc.Name), "Client") buffer, err := util.With("interfaceFn").Parse(text).Execute( map[string]interface{}{ "hasComment": len(comment) > 0, diff --git a/tools/goctl/rpc/generator/genlogic.go b/tools/goctl/rpc/generator/genlogic.go index 808b902c..aa04707e 100644 --- a/tools/goctl/rpc/generator/genlogic.go +++ b/tools/goctl/rpc/generator/genlogic.go @@ -92,14 +92,7 @@ func (g *DefaultGenerator) genLogicFunction(serviceName, goPackage string, rpc * logicName := stringx.From(rpc.Name + "_logic").ToCamel() comment := parser.GetComment(rpc.Doc()) - var streamServer string - if rpc.StreamsRequest && rpc.StreamsReturns { - streamServer = fmt.Sprintf("%s.%s", goPackage, parser.CamelCase(serviceName)+"_StreamServer") - } else if rpc.StreamsRequest { - streamServer = fmt.Sprintf("%s.%s", goPackage, parser.CamelCase(serviceName)+"_ClientStreamServer") - } else { - streamServer = fmt.Sprintf("%s.%s", goPackage, parser.CamelCase(serviceName)+"_ServerStreamServer") - } + streamServer := fmt.Sprintf("%s.%s_%s%s", goPackage, parser.CamelCase(serviceName), parser.CamelCase(rpc.Name), "Server") buffer, err := util.With("fun").Parse(text).Execute(map[string]interface{}{ "logicName": logicName, "method": parser.CamelCase(rpc.Name), diff --git a/tools/goctl/rpc/generator/genserver.go b/tools/goctl/rpc/generator/genserver.go index 6221600d..aa49e1cc 100644 --- a/tools/goctl/rpc/generator/genserver.go +++ b/tools/goctl/rpc/generator/genserver.go @@ -91,15 +91,7 @@ func (g *DefaultGenerator) genFunctions(goPackage string, service parser.Service } comment := parser.GetComment(rpc.Doc()) - var streamServer string - if rpc.StreamsRequest && rpc.StreamsReturns { - streamServer = fmt.Sprintf("%s.%s", goPackage, parser.CamelCase(service.Name)+"_StreamServer") - } else if rpc.StreamsRequest { - streamServer = fmt.Sprintf("%s.%s", goPackage, parser.CamelCase(service.Name)+"_ClientStreamServer") - } else { - streamServer = fmt.Sprintf("%s.%s", goPackage, parser.CamelCase(service.Name)+"_ServerStreamServer") - } - + streamServer := fmt.Sprintf("%s.%s_%s%s", goPackage, parser.CamelCase(service.Name), parser.CamelCase(rpc.Name), "Server") buffer, err := util.With("func").Parse(text).Execute(map[string]interface{}{ "server": stringx.From(service.Name).ToCamel(), "logicName": fmt.Sprintf("%sLogic", stringx.From(rpc.Name).ToCamel()),