mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-10 08:29:58 +08:00
feat: add cmdline argument to control whether generate package name from proto filename (#5387)
This commit is contained in:
@@ -48,6 +48,9 @@ var (
|
||||
VarBoolClient bool
|
||||
// VarStringModule describes the module name for go.mod.
|
||||
VarStringModule string
|
||||
// VarBoolNameFromFilename describes whether to derive service name from proto filename
|
||||
// instead of the proto package name. Default is false (uses package name).
|
||||
VarBoolNameFromFilename bool
|
||||
)
|
||||
|
||||
// RPCNew is to generate rpc greet service, this greet service can speed
|
||||
@@ -94,6 +97,7 @@ func RPCNew(_ *cobra.Command, args []string) error {
|
||||
ctx.ProtocCmd = fmt.Sprintf("protoc -I=%s %s --go_out=%s --go-grpc_out=%s", filepath.Dir(src), filepath.Base(src), filepath.Dir(src), filepath.Dir(src))
|
||||
ctx.IsGenClient = VarBoolClient
|
||||
ctx.Module = VarStringModule
|
||||
ctx.NameFromFilename = VarBoolNameFromFilename
|
||||
|
||||
grpcOptList := VarStringSliceGoGRPCOpt
|
||||
if len(grpcOptList) > 0 {
|
||||
|
||||
@@ -104,6 +104,7 @@ func ZRPC(_ *cobra.Command, args []string) error {
|
||||
ctx.ProtocCmd = strings.Join(protocArgs, " ")
|
||||
ctx.IsGenClient = VarBoolClient
|
||||
ctx.Module = VarStringModule
|
||||
ctx.NameFromFilename = VarBoolNameFromFilename
|
||||
g := generator.NewGenerator(style, verbose)
|
||||
return g.Generate(&ctx)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user