The Exec method doesn't return the rows, it returns driver.Result
and error
.
func (stmt *stmt) Exec(args []driver.Value) (driver.Result, error)
^^^^^^^^^^^^^
And, the driver.Result type has the following definition (comments removed):
type Result interface {
LastInsertId() (int64, error)
RowsAffected() (int64, error)
}
What you're looking for is Query method that returns driver.Rows
:
func (stmt *stmt) Query(args []driver.Value) (driver.Rows, error)
^^^^^^^^^^^
You can then iterate over the rows to generate the array you want.
An example has been listed in the README.md (copied here):
rows, err := connect.Query("SELECT country_code, os_id, browser_id, categories, action_day, action_time FROM example")
if err != nil {
log.Fatal(err)
}
defer rows.Close()
for rows.Next() {
var (
country string
os, browser uint8
categories []int16
actionDay, actionTime time.Time
)
if err := rows.Scan(&country, &os, &browser, &categories, &actionDay, &actionTime); err != nil {
log.Fatal(err)
}
log.Printf("country: %s, os: %d, browser: %d, categories: %v, action_day: %s, action_time: %s", country, os, browser, categories, actionDay, actionTime)
}
Hope that helps!