Kevin Wan 2 年之前
父節點
當前提交
d20d8324e7
共有 2 個文件被更改,包括 14 次插入11 次删除
  1. 9 0
      tools/goctl/api/gogen/config.tpl
  2. 5 11
      tools/goctl/api/gogen/genconfig.go

+ 9 - 0
tools/goctl/api/gogen/config.tpl

@@ -0,0 +1,9 @@
+package config
+
+import {{.authImport}}
+
+type Config struct {
+	rest.RestConf
+	{{.auth}}
+	{{.jwtTrans}}
+}

+ 5 - 11
tools/goctl/api/gogen/genconfig.go

@@ -1,6 +1,7 @@
 package gogen
 
 import (
+	_ "embed"
 	"fmt"
 	"strings"
 
@@ -11,17 +12,7 @@ import (
 )
 
 const (
-	configFile     = "config"
-	configTemplate = `package config
-
-import {{.authImport}}
-
-type Config struct {
-	rest.RestConf
-	{{.auth}}
-	{{.jwtTrans}}
-}
-`
+	configFile = "config"
 
 	jwtTemplate = ` struct {
 		AccessSecret string
@@ -35,6 +26,9 @@ type Config struct {
 `
 )
 
+//go:embed config.tpl
+var configTemplate string
+
 func genConfig(dir string, cfg *config.Config, api *spec.ApiSpec) error {
 	filename, err := format.FileNamingFormat(cfg.NamingFormat, configFile)
 	if err != nil {