feat: support goctl --module to set go module (#5135)

This commit is contained in:
Kevin Wan
2025-08-31 16:40:49 +08:00
committed by GitHub
parent d728a3b2d9
commit 955b8016aa
14 changed files with 944 additions and 6 deletions

View File

@@ -30,6 +30,8 @@ type ZRpcContext struct {
Multiple bool
// Whether to generate rpc client
IsGenClient bool
// Module is the custom module name for go.mod
Module string
}
// Generate generates a rpc service, through the proto file,
@@ -51,7 +53,12 @@ func (g *Generator) Generate(zctx *ZRpcContext) error {
return err
}
projectCtx, err := ctx.Prepare(abs)
var projectCtx *ctx.ProjectContext
if len(zctx.Module) > 0 {
projectCtx, err = ctx.PrepareWithModule(abs, zctx.Module)
} else {
projectCtx, err = ctx.Prepare(abs)
}
if err != nil {
return err
}