Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrDBNotSetUp get gorm db but not set up. ErrDBNotSetUp = errors.New("gorm db not set up") // ErrDBNameNotFound config db name not found. ErrDBNameNotFound = errors.New("db config dbname not found") )
Functions ¶
func GormMySQLByConfig ¶
GormMySQLByConfig set up gorm db with mysql config.
func GormPgSQLByConfig ¶
GormPgSQLByConfig set up gorm db with pg config.
Types ¶
type DBConfig ¶
type DBConfig struct { Type string `mapstructure:"type" json:"type" yaml:"type"` // 类型 mysql/postgresql. Host string `mapstructure:"host" json:"host" yaml:"host"` // 服务器地址. Port string `mapstructure:"port" json:"port" yaml:"port"` // 端口. Config string `mapstructure:"config" json:"config" yaml:"config"` // 高级配置. Dbname string `mapstructure:"dbname" json:"dbname" yaml:"dbname"` // 数据库名. Username string `mapstructure:"username" json:"username" yaml:"username"` // 数据库用户名. Password string `mapstructure:"password" json:"password" yaml:"password"` // 数据库密码. MaxIdleConns int `mapstructure:"max_idle_conns" json:"max_idle_conns" yaml:"maxIdleConns"` // nolint MaxOpenConns int `mapstructure:"max_open_conns" json:"max_open_conns" yaml:"maxOpenConns"` // nolint LogLevel string `mapstructure:"log_level" json:"log_level" yaml:"logLevel"` // nolint }
Click to show internal directories.
Click to hide internal directories.