Skip to content

Commit

Permalink
fix duplicate alias (zeromicro#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
Keson authored Nov 5, 2020
1 parent 88333ee commit f7d778e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tools/goctl/rpc/generator/gencall.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"path/filepath"
"strings"

"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/util"
"github.com/tal-tech/go-zero/tools/goctl/util/stringx"
Expand Down Expand Up @@ -79,15 +80,15 @@ func (g *defaultGenerator) GenCall(ctx DirContext, proto parser.Proto) error {
return err
}

var alias []string
var alias = collection.NewSet()
for _, item := range service.RPC {
alias = append(alias, fmt.Sprintf("%s = %s", parser.CamelCase(item.RequestType), fmt.Sprintf("%s.%s", proto.PbPackage, parser.CamelCase(item.RequestType))))
alias = append(alias, fmt.Sprintf("%s = %s", parser.CamelCase(item.ReturnsType), fmt.Sprintf("%s.%s", proto.PbPackage, parser.CamelCase(item.ReturnsType))))
alias.AddStr(fmt.Sprintf("%s = %s", parser.CamelCase(item.RequestType), fmt.Sprintf("%s.%s", proto.PbPackage, parser.CamelCase(item.RequestType))))
alias.AddStr(fmt.Sprintf("%s = %s", parser.CamelCase(item.ReturnsType), fmt.Sprintf("%s.%s", proto.PbPackage, parser.CamelCase(item.ReturnsType))))
}

err = util.With("shared").GoFmt(true).Parse(text).SaveTo(map[string]interface{}{
"name": formatFilename(service.Name),
"alias": strings.Join(alias, util.NL),
"alias": strings.Join(alias.KeysStr(), util.NL),
"head": head,
"filePackage": formatFilename(service.Name),
"package": fmt.Sprintf(`"%s"`, ctx.GetPb().Package),
Expand Down

0 comments on commit f7d778e

Please sign in to comment.