go-zero/tools/goctl/model/sql/gen/tablename.go
Kevin Wan eab904af64
chore: update goctl interface{} to any (#2819)
* chore: update goctl interface{} to any

* chore: update goctl interface{} to any
2023-01-24 17:51:03 +08:00

27 lines
619 B
Go

package gen
import (
"github.com/zeromicro/go-zero/tools/goctl/model/sql/template"
"github.com/zeromicro/go-zero/tools/goctl/util"
"github.com/zeromicro/go-zero/tools/goctl/util/pathx"
)
func genTableName(table Table) (string, error) {
text, err := pathx.LoadTemplate(category, tableNameTemplateFile, template.TableName)
if err != nil {
return "", err
}
output, err := util.With("tableName").
Parse(text).
Execute(map[string]any{
"tableName": table.Name.Source(),
"upperStartCamelObject": table.Name.ToCamel(),
})
if err != nil {
return "", nil
}
return output.String(), nil
}