-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Based on #4462, it has been improved and is compatible with previous versions #4775
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
base: master
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…kage and package parameters are added
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 custom package names in MongoDB model generation, making it backward compatible with previous versions. The main purpose is to allow users to specify package names other than the hardcoded "model" package.
- Added two new command-line flags:
--auto-package
and--package
for controlling package naming - Updated all template files to use a configurable
{{.PackageName}}
placeholder instead of hardcoded "model" - Enhanced the generation logic to determine package names based on user preferences or directory names
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
tools/goctl/model/mongo/template/*.tpl | Updated package declarations to use configurable PackageName template variable |
tools/goctl/model/mongo/mongo.go | Added package name determination logic and new command-line variables |
tools/goctl/model/mongo/generate/generate.go | Enhanced Context struct and template data to include PackageName |
tools/goctl/model/cmd.go | Added new command-line flag bindings for package configuration |
tools/goctl/internal/flags/default_en.json | Added flag descriptions for new package-related options |
tools/goctl/model/mongo/readme.md | Updated documentation with new flags and examples |
"easy": "Generate code with auto generated CollectionName for easy declare [optional]", | ||
"dir": "{{.goctl.model.dir}}", | ||
"auto-package": "Whether to automatically use the name of the directory where the build file is located as the package name [optional,default=false]\nIt is mainly used to be compatible with previous versions,If this parameter is set to false, the package name is set to model by default", | ||
"package": "Manually specify the package name, which takes precedence over VarBoolPkgAuto [optional]", |
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.
The documentation refers to 'VarBoolPkgAuto' but the actual variable name is 'VarBoolAutoPackage'. This inconsistency could confuse users.
"package": "Manually specify the package name, which takes precedence over VarBoolPkgAuto [optional]", | |
"package": "Manually specify the package name, which takes precedence over VarBoolAutoPackage [optional]", |
Copilot uses AI. Check for mistakes.
// - Whether to automatically use the name of the directory where the build file is located as the package name | ||
// - It is mainly used to be compatible with previous versions,If this parameter is set to false, the package name is set to model by default | ||
VarBoolAutoPackage bool | ||
//VarStringPackage Manually specify the package name, which takes precedence over VarBoolPkgAuto |
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.
The comment refers to 'VarBoolPkgAuto' but the actual variable name is 'VarBoolAutoPackage'. This should be updated for consistency.
//VarStringPackage Manually specify the package name, which takes precedence over VarBoolPkgAuto | |
//VarStringPackage Manually specify the package name, which takes precedence over VarBoolAutoPackage |
Copilot uses AI. Check for mistakes.
基于 #4462 进行了后续完善,兼容了历史版本
支持 mongo 的自定义model package name