use goctl template to generate all kinds of templates
This commit is contained in:
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
"github.com/tal-tech/go-zero/tools/goctl/api/spec"
|
||||
"github.com/tal-tech/go-zero/tools/goctl/api/util"
|
||||
"github.com/tal-tech/go-zero/tools/goctl/templatex"
|
||||
ctlutil "github.com/tal-tech/go-zero/tools/goctl/util"
|
||||
"github.com/tal-tech/go-zero/tools/goctl/vars"
|
||||
)
|
||||
|
||||
@@ -48,7 +48,7 @@ func genConfig(dir string, api *spec.ApiSpec) error {
|
||||
}
|
||||
|
||||
var authImportStr = fmt.Sprintf("\"%s/rest\"", vars.ProjectOpenSourceUrl)
|
||||
text, err := templatex.LoadTemplate(category, configTemplateFile, configTemplate)
|
||||
text, err := ctlutil.LoadTemplate(category, configTemplateFile, configTemplate)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
"github.com/tal-tech/go-zero/tools/goctl/api/spec"
|
||||
"github.com/tal-tech/go-zero/tools/goctl/api/util"
|
||||
"github.com/tal-tech/go-zero/tools/goctl/templatex"
|
||||
ctlutil "github.com/tal-tech/go-zero/tools/goctl/util"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -40,7 +40,7 @@ func genEtc(dir string, api *spec.ApiSpec) error {
|
||||
port = strconv.Itoa(defaultPort)
|
||||
}
|
||||
|
||||
text, err := templatex.LoadTemplate(category, etcTemplateFile, etcTemplate)
|
||||
text, err := ctlutil.LoadTemplate(category, etcTemplateFile, etcTemplate)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
|
||||
"github.com/tal-tech/go-zero/tools/goctl/api/spec"
|
||||
apiutil "github.com/tal-tech/go-zero/tools/goctl/api/util"
|
||||
"github.com/tal-tech/go-zero/tools/goctl/templatex"
|
||||
"github.com/tal-tech/go-zero/tools/goctl/util"
|
||||
"github.com/tal-tech/go-zero/tools/goctl/vars"
|
||||
)
|
||||
@@ -94,7 +93,7 @@ func doGenToFile(dir, handler string, group spec.Group, route spec.Route, handle
|
||||
}
|
||||
defer fp.Close()
|
||||
|
||||
text, err := templatex.LoadTemplate(category, handlerTemplateFile, handlerTemplate)
|
||||
text, err := util.LoadTemplate(category, handlerTemplateFile, handlerTemplate)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import (
|
||||
|
||||
"github.com/tal-tech/go-zero/tools/goctl/api/spec"
|
||||
"github.com/tal-tech/go-zero/tools/goctl/api/util"
|
||||
"github.com/tal-tech/go-zero/tools/goctl/templatex"
|
||||
ctlutil "github.com/tal-tech/go-zero/tools/goctl/util"
|
||||
"github.com/tal-tech/go-zero/tools/goctl/vars"
|
||||
)
|
||||
@@ -94,7 +93,7 @@ func genLogicByRoute(dir string, group spec.Group, route spec.Route) error {
|
||||
requestString = "req " + "types." + strings.Title(route.RequestType.Name)
|
||||
}
|
||||
|
||||
text, err := templatex.LoadTemplate(category, logicTemplateFile, logicTemplate)
|
||||
text, err := ctlutil.LoadTemplate(category, logicTemplateFile, logicTemplate)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
|
||||
"github.com/tal-tech/go-zero/tools/goctl/api/spec"
|
||||
"github.com/tal-tech/go-zero/tools/goctl/api/util"
|
||||
"github.com/tal-tech/go-zero/tools/goctl/templatex"
|
||||
ctlutil "github.com/tal-tech/go-zero/tools/goctl/util"
|
||||
"github.com/tal-tech/go-zero/tools/goctl/vars"
|
||||
)
|
||||
@@ -61,7 +60,7 @@ func genMain(dir string, api *spec.ApiSpec) error {
|
||||
return err
|
||||
}
|
||||
|
||||
text, err := templatex.LoadTemplate(category, mainTemplateFile, mainTemplate)
|
||||
text, err := ctlutil.LoadTemplate(category, mainTemplateFile, mainTemplate)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
|
||||
"github.com/tal-tech/go-zero/tools/goctl/api/spec"
|
||||
"github.com/tal-tech/go-zero/tools/goctl/api/util"
|
||||
"github.com/tal-tech/go-zero/tools/goctl/templatex"
|
||||
ctlutil "github.com/tal-tech/go-zero/tools/goctl/util"
|
||||
"github.com/tal-tech/go-zero/tools/goctl/vars"
|
||||
)
|
||||
@@ -52,7 +51,7 @@ func genServiceContext(dir string, api *spec.ApiSpec) error {
|
||||
return err
|
||||
}
|
||||
|
||||
text, err := templatex.LoadTemplate(category, contextTemplateFile, contextTemplate)
|
||||
text, err := ctlutil.LoadTemplate(category, contextTemplateFile, contextTemplate)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package gogen
|
||||
|
||||
import (
|
||||
"github.com/tal-tech/go-zero/tools/goctl/templatex"
|
||||
"github.com/tal-tech/go-zero/tools/goctl/util"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
@@ -25,5 +25,5 @@ var templates = map[string]string{
|
||||
}
|
||||
|
||||
func GenTemplates(_ *cli.Context) error {
|
||||
return templatex.InitTemplates(category, templates)
|
||||
return util.InitTemplates(category, templates)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user