我把mysql信息從配置文件讀出來。mysql主機(jī),用戶,密碼和數(shù)據(jù)庫(kù)名稱怎么作為變量傳到sql.open()?cfg, err := ini.Load("setting.ini")//cfg.BlockMode = falseif 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")
Go sql.open 連接地址占位符
30秒到達(dá)戰(zhàn)場(chǎng)
2019-01-02 10:46:00