From f34d81ca2c4cb081c6d6b8de751aad930dab07ae Mon Sep 17 00:00:00 2001 From: shenbaise9527 Date: Thu, 23 Sep 2021 14:24:21 +0800 Subject: [PATCH] chore: when run goctl-rpc, the order of proto message aliases should be (#1078) fixed Co-authored-by: steven --- tools/goctl/rpc/generator/gencall.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/goctl/rpc/generator/gencall.go b/tools/goctl/rpc/generator/gencall.go index 58489fc2..cbfad52e 100644 --- a/tools/goctl/rpc/generator/gencall.go +++ b/tools/goctl/rpc/generator/gencall.go @@ -3,6 +3,7 @@ package generator import ( "fmt" "path/filepath" + "sort" "strings" "github.com/emicklei/proto" @@ -95,9 +96,11 @@ func (g *DefaultGenerator) GenCall(ctx DirContext, proto parser.Proto, cfg *conf alias.AddStr(fmt.Sprintf("%s = %s", parser.CamelCase(msgName), fmt.Sprintf("%s.%s", proto.PbPackage, parser.CamelCase(msgName)))) } + aliasKeys := alias.KeysStr() + sort.Strings(aliasKeys) err = util.With("shared").GoFmt(true).Parse(text).SaveTo(map[string]interface{}{ "name": callFilename, - "alias": strings.Join(alias.KeysStr(), util.NL), + "alias": strings.Join(aliasKeys, util.NL), "head": head, "filePackage": dir.Base, "package": fmt.Sprintf(`"%s"`, ctx.GetPb().Package),