|
|
|
@ -41,13 +41,14 @@ func main() {
|
|
|
|
|
|
|
|
|
|
func genMain(dir, rootPkg string, cfg *config.Config, api *spec.ApiSpec) error {
|
|
|
|
|
name := strings.ToLower(api.Service.Name)
|
|
|
|
|
if strings.HasSuffix(name, "-api") {
|
|
|
|
|
name = strings.ReplaceAll(name, "-api", "")
|
|
|
|
|
}
|
|
|
|
|
filename, err := format.FileNamingFormat(cfg.NamingFormat, name)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
configName := filename
|
|
|
|
|
if strings.HasSuffix(filename, "-api") {
|
|
|
|
|
filename = strings.ReplaceAll(filename, "-api", "")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return genFile(fileGenConfig{
|
|
|
|
|
dir: dir,
|
|
|
|
@ -59,7 +60,7 @@ func genMain(dir, rootPkg string, cfg *config.Config, api *spec.ApiSpec) error {
|
|
|
|
|
builtinTemplate: mainTemplate,
|
|
|
|
|
data: map[string]string{
|
|
|
|
|
"importPackages": genMainImports(rootPkg),
|
|
|
|
|
"serviceName": api.Service.Name,
|
|
|
|
|
"serviceName": configName,
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|