I am trying to use the go sql driver to read from database tables and I would like the value to be [ ] Map [String] Interface {}
. The name of the column is the key of the map and the value is of interface {}
. I am adding all the columns to an array. I am using code sample for "RawBytes", for example to start with.
However, in the example, all column values are converted to string
as the following form,
do it for interface {}
There is a way to keep it in the form, so I can do the necessary [] map [string] interface {}
See the answer that is based on my answer. You can do something like this:
var myMap = make (map [string] interface {}) Suspend the rows, err: = db.Query ("SELECT *) from myTable" (turn off) if mistake! = Zero This will work with generic and any table, number of columns etc.
No comments:
Post a Comment