Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ColumnNameTpl = template.Must(template.New("columnNameTpl").Parse(columnNameTpl))
View Source
var HelperTpl = template.Must(template.New("helperTpl").Parse(helperTpl))
View Source
var ImportsHeads = map[string]string{
"string": `"string"`,
"time.Time": `"time"`,
"gorm.Model": `"gorm.io/gorm"`,
"fmt": `"fmt"`,
"datatypes.JSON": `"gorm.io/datatypes"`,
"datatypes.Date": `"gorm.io/datatypes"`,
}
ImportsHeads import head options
View Source
var TableNameTpl = template.Must(template.New("tableNameTpl").Parse(tableNameTpl))
Functions ¶
This section is empty.
Types ¶
type Field ¶
type Field struct {
FieldName string // field name
FieldType string // field type
FieldComment string // field comment
FieldTags map[string][]string // field tags
ColumnDataType string // field column go type.
ColumnName string // field column name in database
}
Field of a struct
func (*Field) AddFieldTag ¶
AddFieldTag Add a tag
func (*Field) RemoveFieldTag ¶
type File ¶
type File struct {
Filename string // file name
PackageName string // package name
Imports map[string]string // import package
Structs []Struct // struct list
IsOutColumnName bool // 是否输出表的列名
}
File a file
func (*File) SetOutColumnName ¶
SetOutColumnName set out column name
type ProtobufField ¶
type ProtobufMessage ¶
type ProtobufMessage struct {
StructName string
StructComment string
TableName string
AbbrTableName string
Fields []ProtobufField
}
type Struct ¶
type Struct struct {
StructName string // struct name
StructComment string // struct comment
StructFields []Field // struct field list
TableName string // table name
CreateTableSQL string // create table SQL
}
Struct define a struct
func (*Struct) AddStructFields ¶
AddStructFields Add one or more fields
func (*Struct) BuildColumnNameTemplate ¶
func (*Struct) BuildProtobufTemple ¶
func (*Struct) BuildTableNameTemplate ¶
Click to show internal directories.
Click to hide internal directories.