Documentation ¶
Index ¶
Constants ¶
View Source
const ( TypePostgres = "postgres" // PostgresSQL 数据库 TypeMysql = "mysql" // Mysql 数据库 TypeSqlite = "sqlite" // sqlite3 数据库 )
View Source
const (
MysqlCharsetUTF8MB4 = "utf8mb4"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { Type string `json:"type" yaml:"type" mapstructure:"type"` MysqlConfig MysqlConfig `json:"mysql" yaml:"mysql" mapstructure:"mysql"` PostgresConfig PostgresConfig `json:"postgres" yaml:"postgres" mapstructure:"postgres"` Sqlite SqliteConfig `json:"sqlite" yaml:"sqlite" mapstructure:"sqlite"` Gorm GormConfig `json:"gorm" yaml:"gorm" mapstructure:"gorm"` }
Config 用于承载数据库配置
type GormConfig ¶
type Model ¶
type MysqlConfig ¶
type MysqlConfig struct { Host string `json:"host" yaml:"host" mapstructure:"host"` Port int `json:"port" yaml:"port" mapstructure:"port"` User string `json:"user" yaml:"user" mapstructure:"user"` Password string `json:"password" yaml:"password" mapstructure:"password"` DBName string `json:"dbname" yaml:"dbname" mapstructure:"dbname"` Charset string `json:"charset" yaml:"charset" mapstructure:"charset"` ParseTime bool `json:"parsetime" yaml:"parsetime" mapstructure:"parsetime"` TimeZone string `json:"timezone" yaml:"timezone" mapstructure:"timezone"` }
MysqlConfig Mysql数据库配置
func (MysqlConfig) Datasource ¶
func (c MysqlConfig) Datasource() (string, error)
Datasource 返回数据库连接地址
type PostgresConfig ¶
type PostgresConfig struct { Host string `json:"host" yaml:"host" mapstructure:"host"` Port int `json:"port" yaml:"port" mapstructure:"port"` User string `json:"user" yaml:"user" mapstructure:"user"` Password string `json:"password" yaml:"password" mapstructure:"password"` DBName string `json:"dbname" yaml:"dbname" mapstructure:"dbname"` SSLMode string `json:"sslmode" yaml:"sslmode" mapstructure:"sslmode"` TimeZone string `json:"timezone" yaml:"timezone" mapstructure:"timezone"` }
PostgresConfig PostgresSQL 数据库配置
func (PostgresConfig) Datasource ¶
func (c PostgresConfig) Datasource() (string, error)
Datasource 返回数据库连接地址
type SqliteConfig ¶
type SqliteConfig struct {
Filepath string `json:"filepath" yaml:"filepath" mapstructure:"filepath"`
}
func (SqliteConfig) Datasource ¶
func (c SqliteConfig) Datasource() (string, error)
Click to show internal directories.
Click to hide internal directories.