From 33f87cf1f0386a0a49f79b461fe52acdc9b63555 Mon Sep 17 00:00:00 2001 From: lovelly <840635577@qq.com> Date: Thu, 12 Aug 2021 14:55:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B8=A6=E4=B8=8B=E5=88=92=E7=BA=BF=E7=9A=84?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE,=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=90=8D=E5=AD=97=E9=94=99=E8=AF=AF=E3=80=82=20(#733)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/goctl/api/gogen/genmain.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/goctl/api/gogen/genmain.go b/tools/goctl/api/gogen/genmain.go index 1af504c4..304c4bf5 100644 --- a/tools/goctl/api/gogen/genmain.go +++ b/tools/goctl/api/gogen/genmain.go @@ -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, }, }) }