Documentation
¶
Index ¶
Constants ¶
View Source
const ( ToFile = LogTo("file") ToStdout = LogTo("stdout") )
Variables ¶
This section is empty.
Functions ¶
func LoadConfigFromToml ¶
如何配置映射成config对象 1. 从toml文件中读取配置
func LoadGlobalDB ¶
func LoadGlobalDB() error
Types ¶
type App ¶
type App struct {
Name string `toml:"name" env:"APP_NAME"`
Host string `toml:"host" env:"APP_HOST"`
Port string `toml:"port" env:"APP_PORT"`
}
func NewDefaultApp ¶
func NewDefaultApp() *App
type Log ¶
type Log struct {
//debug, info, warn, error, dpanic, panic, fatal
Level string `toml:"level" env:"LOG_LEVEL"`
PathDir string `toml:"path_dir" env:"LOG_PATH_DIR"`
Format LogFormat `toml:"format" env:"LOG_FORMAT"`
To LogTo `toml:"to" env:"LOG_TO"`
}
func NewDefaultLog ¶
func NewDefaultLog() *Log
type MySQL ¶
type MySQL struct {
Host string `toml:"host" env:"MYSQL_HOST"`
Port string `toml:"port" env:"MYSQL_PORT"`
UserName string `toml:"username" env:"MYSQL_USERNAME"`
Password string `toml:"password" env:"MYSQL_PASSWORD"`
Database string `toml:"database" env:"MYSQL_DATABASE"`
// 连接池配置,含义:最大空闲连接数
MaxIdleConns int `toml:"max_idle_conns" env:"MYSQL_MAX_IDLE_CONNS"`
// 最大打开连接数,含义:最大连接数
MaxOpenConns int `toml:"max_open_conns" env:"MYSQL_MAX_OPEN_CONNS"`
// 连接最大存活时间,含义:连接最大存活时间
MaxLifetime int `toml:"max_lifetime" env:"MYSQL_MAX_LIFETIME"`
// 连接最大空闲时间,含义:连接最大空闲时间
MaxIdleTime int `toml:"max_idle_time" env:"MYSQL_MAX_IDLE_TIME"`
// contains filtered or unexported fields
}
func NewDefaultMySQL ¶
func NewDefaultMySQL() *MySQL
Click to show internal directories.
Click to hide internal directories.