imports.go 617 B

1234567891011121314151617181920212223242526
  1. package gen
  2. import (
  3. "github.com/tal-tech/go-zero/tools/goctl/model/sql/template"
  4. "github.com/tal-tech/go-zero/tools/goctl/util"
  5. )
  6. func genImports(withCache, timeImport bool) (string, error) {
  7. if withCache {
  8. buffer, err := util.With("import").Parse(template.Imports).Execute(map[string]interface{}{
  9. "time": timeImport,
  10. })
  11. if err != nil {
  12. return "", err
  13. }
  14. return buffer.String(), nil
  15. } else {
  16. buffer, err := util.With("import").Parse(template.ImportsNoCache).Execute(map[string]interface{}{
  17. "time": timeImport,
  18. })
  19. if err != nil {
  20. return "", err
  21. }
  22. return buffer.String(), nil
  23. }
  24. }