mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-24 09:40:24 +08:00
25 lines
506 B
Go
25 lines
506 B
Go
package gen
|
|
|
|
import (
|
|
"bytes"
|
|
"text/template"
|
|
|
|
sqltemplate "github.com/tal-tech/go-zero/tools/goctl/model/sql/template"
|
|
)
|
|
|
|
func genNew(table *InnerTable) (string, error) {
|
|
t, err := template.New("new").Parse(sqltemplate.New)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
newBuffer := new(bytes.Buffer)
|
|
err = t.Execute(newBuffer, map[string]interface{}{
|
|
"containsCache": table.ContainsCache,
|
|
"upperObject": table.UpperCamelCase,
|
|
})
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return newBuffer.String(), nil
|
|
}
|