fix: generate client directory for goctl (#3166)

master
Thirteen 2 years ago committed by GitHub
parent c22bc1c8ea
commit ef410e8083
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,6 +1,7 @@
package generator
import (
"github.com/zeromicro/go-zero/tools/goctl/util/format"
"path/filepath"
"strings"
@ -56,7 +57,7 @@ type (
}
)
func mkdir(ctx *ctx.ProjectContext, proto parser.Proto, _ *conf.Config, c *ZRpcContext) (DirContext,
func mkdir(ctx *ctx.ProjectContext, proto parser.Proto, conf *conf.Config, c *ZRpcContext) (DirContext,
error) {
inner := make(map[string]Dir)
etcDir := filepath.Join(ctx.WorkDir, "etc")
@ -90,8 +91,12 @@ func mkdir(ctx *ctx.ProjectContext, proto parser.Proto, _ *conf.Config, c *ZRpcC
callDir := filepath.Join(ctx.WorkDir,
strings.ToLower(stringx.From(proto.Service[0].Name).ToCamel()))
if strings.EqualFold(proto.Service[0].Name, filepath.Base(proto.GoPackage)) {
callDir = filepath.Join(ctx.WorkDir,
strings.ToLower(stringx.From(proto.Service[0].Name+"_client").ToCamel()))
var err error
clientDir, err = format.FileNamingFormat(conf.NamingFormat, proto.Service[0].Name+"_client")
if err != nil {
return nil, err
}
callDir = filepath.Join(ctx.WorkDir, clientDir)
}
inner[call] = Dir{
Filename: callDir,

Loading…
Cancel
Save