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