feat: Support projectPkg template variables in config, handler, logic, main, and svc template files (#4939)

This commit is contained in:
geekeryy
2025-08-19 20:29:41 +08:00
committed by GitHub
parent 20d20ef861
commit 73d6fcfccd
11 changed files with 42 additions and 34 deletions

View File

@@ -15,7 +15,7 @@ import (
//go:embed main.tpl
var mainTemplate string
func genMain(dir, rootPkg string, cfg *config.Config, api *spec.ApiSpec) error {
func genMain(dir, rootPkg, projectPkg string, cfg *config.Config, api *spec.ApiSpec) error {
name := strings.ToLower(api.Service.Name)
filename, err := format.FileNamingFormat(cfg.NamingFormat, name)
if err != nil {
@@ -38,6 +38,7 @@ func genMain(dir, rootPkg string, cfg *config.Config, api *spec.ApiSpec) error {
data: map[string]string{
"importPackages": genMainImports(rootPkg),
"serviceName": configName,
"projectPkg": projectPkg,
},
})
}