Skip to content

Conversation

lascyb
Copy link
Contributor

@lascyb lascyb commented Apr 11, 2025

基于 #4462 进行了后续完善,兼容了历史版本
支持 mongo 的自定义model package name

Copy link

codecov bot commented Apr 11, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@kevwan kevwan added this to the v1.9.0 milestone Jul 13, 2025
@kevwan kevwan requested review from kesonan and Copilot and removed request for kesonan August 9, 2025 13:24
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 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]",
Copy link
Preview

Copilot AI Aug 9, 2025

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.

Suggested change
"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
Copy link
Preview

Copilot AI Aug 9, 2025

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.

Suggested change
//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.

@kevwan kevwan modified the milestones: v1.9.0, v1.9.1 Aug 17, 2025
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.

2 participants