次のコードで 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"}
2 つの質問:
- 1行ランダムに出力順序が「逆」になるのはなぜですか<----:
map[string]interface {}{"SIGN_NAME":"Chris Walker", "SIGN_ID":"CW"}
- プレフィックスを取り除くにはどうすればよいですか: map[string]interface {}