* optimize performance

* rename

* rename

* revert
This commit is contained in:
kingxt
2021-05-29 23:01:02 +08:00
committed by GitHub
parent 3022f93b6d
commit 546fcd8bab
6 changed files with 25 additions and 44 deletions

View File

@@ -62,7 +62,7 @@ type (
}
)
func genRoutes(dir string, cfg *config.Config, api *spec.ApiSpec) error {
func genRoutes(dir, rootPkg string, cfg *config.Config, api *spec.ApiSpec) error {
var builder strings.Builder
groups, err := getRoutes(api)
if err != nil {
@@ -116,11 +116,6 @@ func genRoutes(dir string, cfg *config.Config, api *spec.ApiSpec) error {
}
}
parentPkg, err := getParentPackage(dir)
if err != nil {
return err
}
routeFilename, err := format.FileNamingFormat(cfg.NamingFormat, routesFilename)
if err != nil {
return err
@@ -139,7 +134,7 @@ func genRoutes(dir string, cfg *config.Config, api *spec.ApiSpec) error {
templateFile: "",
builtinTemplate: routesTemplate,
data: map[string]string{
"importPackages": genRouteImports(parentPkg, api),
"importPackages": genRouteImports(rootPkg, api),
"routesAdditions": strings.TrimSpace(builder.String()),
},
})