fix: generate client directory for goctl (#3166)
This commit is contained in:
@@ -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,
|
||||||
|
|||||||
Reference in New Issue
Block a user