Conversation
- 实现了通过 go get 下载远程 Go 模块作为模板生成新项目的功能 - 支持嵌套 Go 模块路径和 Git 仓库子目录的模板下载 - 增加了交互式模板选择和版本选择功能 - 自动清理生成项目中的 .git、go.work 等文件 - 支持自定义 go.mod 模块路径和依赖升级到最新版本 - 增加了对 Go 和 Git 环境的检查 - 实现了版本信息获取和选择的功能
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enhances the gf init command with support for initializing GoFrame projects from remote templates, including interactive template selection, version selection, and git subdirectory support. The changes introduce a new geninit package that modularizes template initialization logic and provides both CLI and interactive workflows.
Key changes:
- Added remote template initialization via
--repo/-rflag with support for Git subdirectories - Implemented interactive mode (
--interactive/-i) for template and configuration selection - Added version selection capability (
--select/-s) for choosing specific template versions - Created modular
geninitpackage with specialized handlers for downloads, AST transformations, and project generation
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 20 comments.
Show a summary per file
| File | Description |
|---|---|
cmd/gf/internal/cmd/cmd_init.go |
Updated command entry point with new flags, interactive mode, and routing logic for remote vs built-in templates |
cmd/gf/internal/cmd/geninit/geninit.go |
Core orchestration logic for processing remote templates via Go modules or Git subdirectories |
cmd/gf/internal/cmd/geninit/geninit_version.go |
Module version fetching and parsing using go list commands |
cmd/gf/internal/cmd/geninit/geninit_selector.go |
Interactive version selection UI with display limiting |
cmd/gf/internal/cmd/geninit/geninit_git_downloader.go |
Git sparse checkout implementation for subdirectory templates with URL parsing heuristics |
cmd/gf/internal/cmd/geninit/geninit_generator.go |
Project generation logic including file copying, cleanup, and dependency management |
cmd/gf/internal/cmd/geninit/geninit_env.go |
Environment validation for Go and Git installations |
cmd/gf/internal/cmd/geninit/geninit_downloader.go |
Go module download via go get with fallback version strategies |
cmd/gf/internal/cmd/geninit/geninit_ast.go |
AST-based import path replacement for module renaming |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
houseme
approved these changes
Dec 26, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a significant enhancement to the
gf initcommand by adding support for initializing GoFrame projects from remote templates, including interactive and advanced options for template selection. The changes include new interactive flows, support for remote repositories (including git subdirectories), and modularization of the template initialization logic into a newgeninitpackage.The most important changes are:
New Features & Interactive Initialization
--repo/-rflag, interactive mode (--interactive/-i), and version selection (--select/-s). Users can now select built-in or remote templates, specify custom repositories, and interactively choose project configuration. (cmd/gf/internal/cmd/cmd_init.go) [1] [2] [3]cmd/gf/internal/cmd/cmd_init.go)Code Organization & Modularization
geninit, with a clear API for processing templates, handling Go/gomod/git environments, and managing project generation. (cmd/gf/internal/cmd/geninit/geninit.go)geninit_env.go), template downloading (geninit_downloader.go), and AST-based Go import path replacement (geninit_ast.go). [1] [2] [3]Usability Improvements
cmd/gf/internal/cmd/cmd_init.go)These changes greatly improve the flexibility and user experience of project initialization in GoFrame, enabling both simple and advanced workflows.