I read the mysql information from the configuration file. How do mysql hosts, users, passwords, and database names be passed to sql.open () as variables?
cfg, err := ini.Load("setting.ini")
//cfg.BlockMode = false
if err != nil {
panic(err)
}
mysqlhost := cfg.Section("mysql").Key("host").String()
mysqluser := cfg.Section("mysql").Key("user").String()
mysqlpassword := cfg.Section("mysql").Key("password").String()
mysqldatabase := cfg.Section("mysql").Key("database").String()
dbconn, err = sql.Open("mysql", "%s:%s@tcp(%s)/%s?charset=utf8&parseTime=True&loc=Local")