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 package generator
import ( import (
"github.com/zeromicro/go-zero/tools/goctl/util/format"
"path/filepath" "path/filepath"
"strings" "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) { error) {
inner := make(map[string]Dir) inner := make(map[string]Dir)
etcDir := filepath.Join(ctx.WorkDir, "etc") 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, callDir := filepath.Join(ctx.WorkDir,
strings.ToLower(stringx.From(proto.Service[0].Name).ToCamel())) strings.ToLower(stringx.From(proto.Service[0].Name).ToCamel()))
if strings.EqualFold(proto.Service[0].Name, filepath.Base(proto.GoPackage)) { if strings.EqualFold(proto.Service[0].Name, filepath.Base(proto.GoPackage)) {
callDir = filepath.Join(ctx.WorkDir, var err error
strings.ToLower(stringx.From(proto.Service[0].Name+"_client").ToCamel())) 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{ inner[call] = Dir{
Filename: callDir, Filename: callDir,

Loading…
Cancel
Save