2021-08-20 14:59:13 +08:00
|
|
|
package config
|
2021-08-20 15:15:05 +08:00
|
|
|
|
|
|
|
// 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,
|
|
|
|
}
|
|
|
|
}
|