go-zero/tools/goctl/model/sql/gen/imports.go

27 lines
632 B
Go
Raw Normal View History

2020-07-29 17:11:41 +08:00
package gen
import (
"github.com/tal-tech/go-zero/tools/goctl/model/sql/template"
2020-10-15 16:36:49 +08:00
"github.com/tal-tech/go-zero/tools/goctl/templatex"
2020-07-29 17:11:41 +08:00
)
func genImports(withCache, timeImport bool) (string, error) {
if withCache {
2020-10-15 16:36:49 +08:00
buffer, err := templatex.With("import").Parse(template.Imports).Execute(map[string]interface{}{
"time": timeImport,
})
if err != nil {
return "", err
}
return buffer.String(), nil
} else {
2020-10-15 16:36:49 +08:00
buffer, err := templatex.With("import").Parse(template.ImportsNoCache).Execute(map[string]interface{}{
"time": timeImport,
})
if err != nil {
return "", err
}
return buffer.String(), nil
2020-07-29 17:11:41 +08:00
}
}