Documentation ¶
Index ¶
- Variables
- func Byte2Int64(data []byte) int64
- func CamelCase(str, prefix string, ucFirst bool) string
- func CaseCamel(str string) string
- func LcFirst(s string) string
- func Tab(depth int) string
- func UcFirst(s string) string
- type Column
- type Convert
- func (convert *Convert) GetStyle() string
- func (convert *Convert) Run()
- func (convert *Convert) SetIgnoreTables(table ...string)
- func (convert *Convert) SetModelPath(path string)
- func (convert *Convert) SetPackageName(name string)
- func (convert *Convert) SetStyle(name string)
- func (convert *Convert) SetTablePrefix(table, prefix string)
- type Format
- type MysqlToGo
- func (mtg *MysqlToGo) Connect() error
- func (mtg *MysqlToGo) GetDriverType() string
- func (mtg *MysqlToGo) GetDsn() string
- func (mtg *MysqlToGo) GetTables() (tables []string)
- func (mtg *MysqlToGo) ReadTablesColumns(table string) []Column
- func (mtg *MysqlToGo) SetDsn(dsn string, options ...interface{})
- type PropertyFormat
- type SqlDriver
Constants ¶
This section is empty.
Variables ¶
View Source
var GormInit = `` /* 235-byte string literal not displayed */
View Source
var GormTpl = `` /* 984-byte string literal not displayed */
View Source
var TypeMappingMysqlToGo = map[string]string{
"int": "int",
"integer": "int",
"tinyint": "int8",
"smallint": "int16",
"mediumint": "int32",
"bigint": "int64",
"int unsigned": "int",
"integer unsigned": "int",
"tinyint unsigned": "int8",
"smallint unsigned": "int16",
"mediumint unsigned": "int32",
"bigint unsigned": "int64",
"bit": "int8",
"bool": "bool",
"enum": "string",
"set": "string",
"varchar": "string",
"char": "string",
"tinytext": "string",
"mediumtext": "string",
"text": "string",
"longtext": "string",
"blob": "string",
"tinyblob": "string",
"mediumblob": "string",
"longblob": "string",
"date": "string",
"datetime": "string",
"timestamp": "string",
"time": "string",
"float": "float32",
"double": "float64",
"decimal": "float64",
"binary": "[]byte",
"varbinary": "[]byte",
}
Functions ¶
func Byte2Int64 ¶
Types ¶
type Column ¶
type Column struct { ColumnName string Type string Nullable string TableName string ColumnComment string Tag string MaxLength int64 NumberPrecision int64 ColumnType string ColumnKey string Default interface{} }
func (Column) GetMysqlType ¶
func (Column) IsAllowEmpty ¶
func (Column) IsPrimaryKey ¶
type Convert ¶
type Convert struct { ModelPath string // save path Style string // tab key save like gorm ,orm ,bee orm...... PackageName string // go package name TablePrefix map[string]string //if table exists prefix TableColumn map[string][]Column //key is table , value is Column list IgnoreTables []string // ignore tables Tables []string // all tables Driver SqlDriver // impl SqlDriver instance // contains filtered or unexported fields }
func GetMysqlToGo ¶
func GetMysqlToGo() *Convert
func (*Convert) Run ¶
func (convert *Convert) Run()
run 1. connect 2. getTable 3. getColumns 4. build 5. write file
func (*Convert) SetIgnoreTables ¶
set model save path
func (*Convert) SetModelPath ¶
set model save path
func (*Convert) SetPackageName ¶
set model save path
func (*Convert) SetTablePrefix ¶
set table prefix if exists replace prefix to empty string
type Format ¶
type Format struct { Framework string TabFormat string // format must use 3 %s in it, first column name, second property third json name AutoInfo string PropertyFormat PropertyFormat // like size s JsonUseCamel bool }
var BeeFormat Format
`gorm:"column:beast_id"`
var DefaultFormat Format
var GormFormat Format
func (Format) AutoImport ¶
func (Format) GetFuncTemplate ¶
func (Format) GetInitTemplate ¶
func (Format) GetPropertyFormat ¶
func (format Format) GetPropertyFormat() PropertyFormat
func (Format) GetTabFormat ¶
type MysqlToGo ¶
type MysqlToGo struct { Dsn string // contains filtered or unexported fields }
func (*MysqlToGo) GetDriverType ¶
func (*MysqlToGo) ReadTablesColumns ¶
read struct from db
type PropertyFormat ¶
func (PropertyFormat) GetDefaultFormat ¶
func (pf PropertyFormat) GetDefaultFormat() string
func (PropertyFormat) GetIndexFormat ¶
func (pf PropertyFormat) GetIndexFormat() string
func (PropertyFormat) GetSizeFormat ¶
func (pf PropertyFormat) GetSizeFormat() string
func (PropertyFormat) GetTypeFormat ¶
func (pf PropertyFormat) GetTypeFormat() string
Click to show internal directories.
Click to hide internal directories.