Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// Driver 驱动名称
// [-MySQL] mysql
// [-PgSQL] pgx
// [SQLite] sqlite3
Driver string `json:"driver" mapstructure:"driver"`
// DSN 数据源名称
//
// [-MySQL] <username>:<password>@tcp(<host>:3306)/<db>?timeout=10s&charset=utf8mb4&parseTime=True&loc=Local
// [-PgSQL] postgres://<username>:<password>@<host>:5432/<dbname>
// [SQLite] file::memory:?cache=shared || file:</path/test.db>
DSN string `json:"dsn" mapstructure:"dsn"`
// Options 数据库连接池选项
Options Options `json:"options" mapstructure:"options"`
}
Config 数据库初始化配置
type Options ¶ added in v0.9.1
type Options struct {
// MaxOpenConns 设置最大可打开的连接数
MaxOpenConns int `json:"max_open_conns" mapstructure:"max_open_conns"`
// MaxIdleConns 连接池最大闲置连接数
MaxIdleConns int `json:"max_idle_conns" mapstructure:"max_idle_conns"`
// ConnMaxIdleTime 连接最大闲置时间(单位:秒)
ConnMaxIdleTime int `json:"conn_max_idle_time" mapstructure:"conn_max_idle_time"`
// ConnMaxLifetime 连接的最大生命时长(单位:秒)
ConnMaxLifetime int `json:"conn_max_lifetime" mapstructure:"conn_max_lifetime"`
}
Click to show internal directories.
Click to hide internal directories.