Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // [mysql] MySQL *MySQL `json:"mysql" toml:"mysql"` // [http] Http *Http `json:"http" toml:"http"` }
程序的配置对象 config --> object
func DefaultConfig ¶
func DefaultConfig() *Config
func LoadConfigFromEnv ¶
通过环境变量读取配置 采用第三方库: "github.com/caarlos0/env/v6" 读取环境变量 环境变量 ---> config object
func LoadConfigFromToml ¶
toml 文件加载 使用到的第三方库: "github.com/BurntSushi/toml"
func (*Config) String ¶
Stringer is implemented by any value that has a String method, which defines the “native” format for that value. The String method is used to print values passed as an operand to any format that accepts a string or to an unformatted printer // such as Print.
type Stringer interface { String() string }
格式化成一个json
type Http ¶
type MySQL ¶
type MySQL struct { Host string `json:"host" toml:"host"` Port int `json:"port" toml:"port"` DB string `json:"db" toml:"db"` Username string `json:"username" toml:"username"` Password string `json:"password" toml:"password"` // 高级参数 MaxOpenConn int `toml:"max_open_conn" env:"MYSQL_MAX_OPEN_CONN"` MaxIdleConn int `toml:"max_idle_conn" env:"MYSQL_MAX_IDLE_CONN"` MaxLifeTime int `toml:"max_life_time" env:"MYSQL_MAX_LIFE_TIME"` MaxIdleTime int `toml:"max_idle_time" env:"MYSQL_MAX_IDLE_TIME"` // contains filtered or unexported fields }
host = "127.0.0.1" port = 3306 db = "vblog" username = "admin" password = "123456"
func (*MySQL) GetConnPool ¶
获取连接池对象, 驱动: _ "github.com/go-sql-driver/mysql" 适配标准库: sql.DB, 连接池(在驱动层之上)
Click to show internal directories.
Click to hide internal directories.