Skip to content

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

Merged
merged 2 commits into from
Aug 19, 2025

Conversation

geekeryy
Copy link
Contributor

@geekeryy geekeryy commented Jun 11, 2025

Support projectPkg template variables in config, handler, logic, main, and svc template files to facilitate highly customized templates for your own projects

@geekeryy geekeryy changed the title feat: Support rootPkg template variables feat: Support projectPkg template variables in config, handler, logic, main, and svc template files Jun 11, 2025
@kevwan kevwan requested review from Copilot and kesonan June 11, 2025 16:05
Copy link
Contributor

@Copilot Copilot AI left a 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 capture projectPkg 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 for config.tpl to verify that projectPkg is correctly rendered in generated output.
"projectPkg": projectPkg,

@geekeryy
Copy link
Contributor Author

@kesonan

Copy link

codecov bot commented Jun 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@geekeryy
Copy link
Contributor Author

@kevwan Can this fix be merged?

@kevwan kevwan added this pull request to the merge queue Aug 19, 2025
Merged via the queue into zeromicro:master with commit 73d6fcf Aug 19, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants