Fix/issue#1447 (#1458)

* Add data for template to render

* fix #1447

Co-authored-by: anqiansong <anqiansong@bytedance.com>
This commit is contained in:
anqiansong
2022-01-18 10:36:38 +08:00
committed by GitHub
parent bf2feee5b7
commit e57fa8ff53
12 changed files with 33 additions and 14 deletions

View File

@@ -6,7 +6,7 @@ import (
"github.com/tal-tech/go-zero/tools/goctl/util/pathx"
)
func genImports(withCache, timeImport bool) (string, error) {
func genImports(withCache, timeImport bool, table Table) (string, error) {
if withCache {
text, err := pathx.LoadTemplate(category, importsTemplateFile, template.Imports)
if err != nil {
@@ -15,6 +15,7 @@ func genImports(withCache, timeImport bool) (string, error) {
buffer, err := util.With("import").Parse(text).Execute(map[string]interface{}{
"time": timeImport,
"data": table,
})
if err != nil {
return "", err
@@ -30,6 +31,7 @@ func genImports(withCache, timeImport bool) (string, error) {
buffer, err := util.With("import").Parse(text).Execute(map[string]interface{}{
"time": timeImport,
"data": table,
})
if err != nil {
return "", err