28 lines
611 B
Go
28 lines
611 B
Go
package config
|
|
|
|
// MySQL配置
|
|
type mysqlConfig struct {
|
|
Host string // 主机
|
|
Port string // 端口
|
|
Username string // 用户名
|
|
Password string // 密码
|
|
DbName string // 数据库名称
|
|
}
|
|
|
|
// InitMySQLConfig 初始化OSS配置
|
|
func InitMySQLConfig() {
|
|
host := getEnvVal("MYSQL_HOST", "mysql")
|
|
port := getEnvVal("MYSQL_PORT", "3306")
|
|
user := getEnvVal("MYSQL_USER", "root")
|
|
password := getEnvVal("MYSQL_PWD", "root")
|
|
dbName := getEnvVal("MYSQL_DB", "go_api")
|
|
|
|
MySQLConfig = mysqlConfig{
|
|
Host: host,
|
|
Port: port,
|
|
Username: user,
|
|
Password: password,
|
|
DbName: dbName,
|
|
}
|
|
}
|