|
|
@ -2,10 +2,11 @@ package gogen
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"bytes"
|
|
|
|
|
|
|
|
"fmt"
|
|
|
|
"text/template"
|
|
|
|
"text/template"
|
|
|
|
|
|
|
|
|
|
|
|
"zero/tools/goctl/api/spec"
|
|
|
|
|
|
|
|
"zero/tools/goctl/api/util"
|
|
|
|
"zero/tools/goctl/api/util"
|
|
|
|
|
|
|
|
"zero/tools/goctl/vars"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
const (
|
|
|
@ -13,7 +14,6 @@ const (
|
|
|
|
configTemplate = `package config
|
|
|
|
configTemplate = `package config
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"zero/rest"
|
|
|
|
|
|
|
|
{{.authImport}}
|
|
|
|
{{.authImport}}
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -23,7 +23,7 @@ type Config struct {
|
|
|
|
`
|
|
|
|
`
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
func genConfig(dir string, api *spec.ApiSpec) error {
|
|
|
|
func genConfig(dir string) error {
|
|
|
|
fp, created, err := util.MaybeCreateFile(dir, configDir, configFile)
|
|
|
|
fp, created, err := util.MaybeCreateFile(dir, configDir, configFile)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
return err
|
|
|
@ -33,7 +33,7 @@ func genConfig(dir string, api *spec.ApiSpec) error {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
defer fp.Close()
|
|
|
|
defer fp.Close()
|
|
|
|
|
|
|
|
|
|
|
|
var authImportStr = ""
|
|
|
|
var authImportStr = fmt.Sprintf("\"%s/rest\"", vars.ProjectOpenSourceUrl)
|
|
|
|
t := template.Must(template.New("configTemplate").Parse(configTemplate))
|
|
|
|
t := template.Must(template.New("configTemplate").Parse(configTemplate))
|
|
|
|
buffer := new(bytes.Buffer)
|
|
|
|
buffer := new(bytes.Buffer)
|
|
|
|
err = t.Execute(buffer, map[string]string{
|
|
|
|
err = t.Execute(buffer, map[string]string{
|
|
|
|