Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (*Client) GetTableColumnInfo ¶
func (c *Client) GetTableColumnInfo(dbName, tableName string) ([]*define.TableColumn, error)
GetTableColumnInfo 查询 information_schema.COLUMNS 表,获取指定表的列信息
func (*Client) GetTableDDL ¶
GetTableDDL 获取表结构
type Config ¶
type Config struct { DBType string `toml:"DBType" yaml:"db_type"` // 数据库驱动类型 Host string `toml:"Host" yaml:"host"` // 主机地址 Port int `toml:"Port" yaml:"port"` // 端口号 DBName string `toml:"DBName" yaml:"db_name"` // 数据库名 UserName string `toml:"UserName" yaml:"user_name"` // 用户名 PassWord string `toml:"PassWord" yaml:"pass_word"` // 密码 CharSet string `toml:"CharSet" yaml:"char_set"` // 字符集 MaxIdleConns int `toml:"MaxIdleConns" yaml:"max_idle_conns"` MaxOpenConns int `toml:"MaxOpenConns" yaml:"max_open_conns"` ConnMaxLifetime int `toml:"ConnMaxLifetime" yaml:"conn_max_lifetime"` LogMode bool `toml:"LogMode" yaml:"log_mode"` }
Config 数据库配置
type StructColumn ¶
StructColumn 存储转换后的 Go 结构体中的所有字段信息
type StructTemplate ¶
type StructTemplate struct { FilePath string // 输出文件路径 // contains filtered or unexported fields }
func NewStructTemplate ¶
func NewStructTemplate() *StructTemplate
func (*StructTemplate) AssemblyColumns ¶
func (t *StructTemplate) AssemblyColumns(tbColumns []*define.TableColumn) []*StructColumn
AssemblyColumns 对通过查询 COLUMNS 表所组装得到的 tbColumns 进行进一步的分解和转换
func (*StructTemplate) Generate ¶
func (t *StructTemplate) Generate(tableName string, tmpColumns []*StructColumn) error
Generate 用转换之后的结构体去渲染模版 template.Must 方法判断返回的 *Template 是否有错误,引发panic,导致程序崩溃(如果模版解析错误,则直接让程序挂掉)
type StructTemplateDB ¶
type StructTemplateDB struct { TableName string Columns []*StructColumn }
StructTemplateDB 存储最终用于渲染的模版对象信息
Click to show internal directories.
Click to hide internal directories.