new.go 556 B

12345678910111213141516171819202122232425
  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 genNew(table Table, withCache bool) (string, error) {
  7. text, err := util.LoadTemplate(category, modelNewTemplateFile, template.New)
  8. if err != nil {
  9. return "", err
  10. }
  11. output, err := util.With("new").
  12. Parse(text).
  13. Execute(map[string]interface{}{
  14. "withCache": withCache,
  15. "upperStartCamelObject": table.Name.ToCamel(),
  16. })
  17. if err != nil {
  18. return "", err
  19. }
  20. return output.String(), nil
  21. }