使用此代码在Golang中使用sqlx:
rows, err := db.Queryx(`SELECT "SIGN_ID","SIGN_NAME" FROM sign`)
for rows.Next() {
results := make(map[string]interface{})
err = rows.MapScan(results)
fmt.Printf("%#v\n", results)
}
结果看起来很有希望:
map[string]interface {}{"SIGN_ID":"JD", "SIGN_NAME":"John Doe"}
map[string]interface {}{"SIGN_ID":"JAD", "SIGN_NAME":"Jane Doe"}
map[string]interface {}{"SIGN_ID":"DD", "SIGN_NAME":"Donald Duck"}
map[string]interface {}{"SIGN_NAME":"Chris Walker", "SIGN_ID":"CW"} <----
map[string]interface {}{"SIGN_ID":"SN", "SIGN_NAME":"St Nicolas"}
两个问题:
map [string] interface {} {&#34; SIGN_NAME&#34;:&#34; Chris Walker&#34;,&#34; SIGN_ID&#34;:&#34; CW&#34;}