Skip to content

refactor(cmd/gf): improve code structure for readability and maintainability#4771

Merged
hailaz merged 1 commit into
masterfrom
fix/gfinit
May 14, 2026
Merged

refactor(cmd/gf): improve code structure for readability and maintainability#4771
hailaz merged 1 commit into
masterfrom
fix/gfinit

Conversation

@hailaz

@hailaz hailaz commented May 14, 2026

Copy link
Copy Markdown
Contributor

Refactor the code structure to enhance readability and maintainability without altering functionality.

fixed #4750 #4757 #4767

另外使用gf init -r github.com/gogf/template-single my-project方式没有问题

合并后v2.10.2生效

Copilot AI review requested due to automatic review settings May 14, 2026 07:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 updates gf init project generation to preserve local template imports and refreshes the bundled templates used by the CLI, addressing initialization failures where generated projects could not compile due to missing v1 imports.

Changes:

  • Replaces built-in template formatting with go/format via exported geninit.FormatGoFiles.
  • Refreshes packed template resources for single, mono, and mono-app templates.
  • Updates Makefile packing flow and uses perl for cross-platform template text replacement.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
Makefile Runs cmd/gf template packing during version updates.
cmd/gf/Makefile Switches mono-app template replacement from sed to perl.
cmd/gf/internal/packed/template-single.go Refreshes packed single-project template resource.
cmd/gf/internal/packed/template-mono.go Refreshes packed mono-repo template resource.
cmd/gf/internal/packed/template-mono-app.go Refreshes packed mono-app template resource.
cmd/gf/internal/cmd/geninit/geninit_generator.go Exports FormatGoFiles and uses it during remote template generation.
cmd/gf/internal/cmd/cmd_init.go Uses FormatGoFiles for built-in template generation to avoid goimports import rewriting.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@hailaz hailaz merged commit 72733e0 into master May 14, 2026
36 checks passed
@hailaz hailaz deleted the fix/gfinit branch May 14, 2026 07:34
StrangeYear pushed a commit to StrangeYear/gf that referenced this pull request Jun 2, 2026
…ability (gogf#4771)

Refactor the code structure to enhance readability and maintainability
without altering functionality.

fixed gogf#4750 gogf#4757 gogf#4767

另外使用`gf init -r github.com/gogf/template-single my-project`方式没有问题

合并后v2.10.2生效
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.

gf 2.10.x win11 64

3 participants