new.go 466 B

12345678910111213141516171819
  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/templatex"
  5. )
  6. func genNew(table Table, withCache bool) (string, error) {
  7. output, err := templatex.With("new").
  8. Parse(template.New).
  9. Execute(map[string]interface{}{
  10. "withCache": withCache,
  11. "upperStartCamelObject": table.Name.Snake2Camel(),
  12. })
  13. if err != nil {
  14. return "", err
  15. }
  16. return output.String(), nil
  17. }