Documentation
¶
Index ¶
- Variables
- func IntoAbbrTableName(tableName string) string
- func IntoComment(comment, defaultComment, old, new string) string
- func IntoImports(s []*Struct) map[string]struct{}
- type Field
- type FieldTagValues
- type FieldTags
- func (f *FieldTags) Add(key string, tagValue *FieldTagValues) *FieldTags
- func (f *FieldTags) AddTagValue(key, value string) *FieldTags
- func (f *FieldTags) Get(key string) *FieldTagValues
- func (f *FieldTags) IntoFieldTag() string
- func (f *FieldTags) Remove(key string) *FieldTags
- func (f *FieldTags) RemoveTagValue(key, value string) *FieldTags
- func (f *FieldTags) SetTagSeparate(key, sep string) *FieldTags
- type File
- type ProtobufMessageField
- type SqlFile
- type Struct
- type TableAttribute
Constants ¶
This section is empty.
Variables ¶
View Source
var ImportsHeads = map[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
Functions ¶
func IntoAbbrTableName ¶ added in v0.3.0
IntoAbbrTableName 获取表名缩写
func IntoComment ¶ added in v0.3.0
IntoComment 转换注释
func IntoImports ¶ added in v0.3.0
Types ¶
type Field ¶
type Field struct {
FieldName string // field name
FieldType string // field type
FieldComment string // field comment
FieldTag string // field tag merge from FieldTags
IsNullable bool // field is null or not
IsTimestamp bool // field Go Type is time.Time
ColumnGoType string // field column go type
ColumnName string // field column name in database
Type string // field sql type, e.g. varchar(255) NOT NULL DEFAULT ”
IsSkipColumn bool // skip filed use for output column
}
Field of a struct
FieldName FieldType FieldTags FieldComment
| | | |
v v v v
Foo int `json:"foo,omitempty yaml:"foo,omitempty"` // 我是一个注释
FieldTag
key v1 sep v2 ... | | | v v v json:"foo,omitempty"
type FieldTagValues ¶ added in v0.3.0
type FieldTagValues struct {
Separate string // tag separate like [",", ";", " "]
Value []string // tag value
}
FieldTagValues field tag values
func NewFiledTagValues ¶ added in v0.3.0
func NewFiledTagValues() *FieldTagValues
NewFiledTagValues new FieldTagValues instance with default separate `,`.
func (*FieldTagValues) AddValue ¶ added in v0.3.0
func (f *FieldTagValues) AddValue(value string) *FieldTagValues
AddValue add value
func (*FieldTagValues) IsZero ¶ added in v0.3.0
func (f *FieldTagValues) IsZero() bool
IsZero value number is zero
func (*FieldTagValues) RemoveValue ¶ added in v0.3.0
func (f *FieldTagValues) RemoveValue(value string) *FieldTagValues
RemoveValue remove value
func (*FieldTagValues) SetSeparate ¶ added in v0.3.0
func (f *FieldTagValues) SetSeparate(separate string) *FieldTagValues
SetSeparate set separate.
type FieldTags ¶ added in v0.3.0
type FieldTags struct {
// contains filtered or unexported fields
}
FieldTags contains multiple tags
key v1 sep v2 ... | | | v v v json:"foo,omitempty"
func NewFieldTags ¶ added in v0.3.0
func NewFieldTags() *FieldTags
func (*FieldTags) Add ¶ added in v0.3.0
func (f *FieldTags) Add(key string, tagValue *FieldTagValues) *FieldTags
Add add a tag.
func (*FieldTags) AddTagValue ¶ added in v0.3.0
AddTagValue add a tag value
func (*FieldTags) Get ¶ added in v0.3.0
func (f *FieldTags) Get(key string) *FieldTagValues
Get Add a tag
func (*FieldTags) IntoFieldTag ¶ added in v0.3.0
func (*FieldTags) RemoveTagValue ¶ added in v0.3.0
RemoveTagValue remove a tag value
func (*FieldTags) SetTagSeparate ¶ added in v0.3.0
SetTagSeparate set the tag separate
type File ¶
type File struct {
Version string
Filename string // file name
PackageName string // package name
Imports map[string]struct{} // import package
Structs []*Struct // struct list in file
// for other use, for example proto
Package string // package
Options map[string]string // options
HasColumn bool // has column
HasHelper bool // has helper
}
File a file
type ProtobufMessageField ¶
type ProtobufMessageField struct {
FieldDataType string // 列数据类型
FieldName string // 列名称
FieldComment string // 列注释
FieldAnnotation string // 列注解
IsTimestamp bool // 是否是时间类型
}
func ParseProtobuf ¶ added in v0.3.0
func ParseProtobuf(structFields []Field, enableGogo, enableSea bool) []ProtobufMessageField
type SqlFile ¶ added in v0.3.0
type SqlFile struct {
Version string
Tables []TableAttribute
}
type Struct ¶
type Struct struct {
StructName string // struct name
StructComment string // struct comment
StructFields []Field // struct field list
TableName string // struct table name in database.
AbbrTableName string // struct abbreviate table name
CreateTableSQL string // create table SQL
ProtoMessageFields []ProtobufMessageField // proto message field
}
Struct define a struct
type TableAttribute ¶ added in v0.3.0
Click to show internal directories.
Click to hide internal directories.