-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
feat: Support projectPkg template variables in config, handler, logic, main, and svc template files #4939
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for a new projectPkg
template variable across Go Zero code generators, allowing templates to reference the module path directly.
- Extended
GetParentPackage
to return both the generated package path and the project’s module path. - Updated generator functions (config, main, service context, routes, handlers, logic, and their tests) to accept and pass
projectPkg
. - Adjusted
DoGenProject
to captureprojectPkg
and supply it to all relevant generators.
Reviewed Changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
tools/goctl/quickstart/mono.go | Adapted calls to GetParentPackage to accept the extra return value. |
tools/goctl/pkg/golang/path.go | Changed GetParentPackage signature to return module path. |
tools/goctl/api/gogen/gensvc.go | Added projectPkg parameter and template data entry. |
tools/goctl/api/gogen/genroutes.go | Added projectPkg parameter and template data entry. |
tools/goctl/api/gogen/genmain.go | Added projectPkg parameter and template data entry. |
tools/goctl/api/gogen/genlogictest.go | Added projectPkg parameter and template data entry. |
tools/goctl/api/gogen/genlogic.go | Added projectPkg parameter and template data entry. |
tools/goctl/api/gogen/genhandlerstest.go | Added projectPkg parameter and template data entry. |
tools/goctl/api/gogen/genhandlers.go | Added projectPkg parameter and template data entry. |
tools/goctl/api/gogen/genconfig.go | Added projectPkg parameter and template data entry. |
tools/goctl/api/gogen/gen.go | Captures projectPkg via GetParentPackage and passes it to all generators. |
Comments suppressed due to low confidence (1)
tools/goctl/api/gogen/genconfig.go:63
- New template variable
projectPkg
is injected into the config generator; consider adding a unit test forconfig.tpl
to verify thatprojectPkg
is correctly rendered in generated output.
"projectPkg": projectPkg,
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
@kevwan Can this fix be merged? |
…ain, svc template files
…, main, svc template files
Support projectPkg template variables in config, handler, logic, main, and svc template files to facilitate highly customized templates for your own projects