I found an answer about how to call the Scan variadic function in Golang using reflection. And don't have reputation to ask in there.
Here the main part of code:
values := make([]interface{}, count)
valuePtrs := make([]interface{}, count)
for rows.Next() {
for i, _ := range columns {
valuePtrs[i] = &values[i]
}
rows.Scan(valuePtrs...)
...
}
And I don't get why is this statement have to be looped?
for i, _ := range columns { valuePtrs[i] = &values[i] }
Would valuePtrs be different on each iteration in golang? Or it's just mistake?
Aucun commentaire:
Enregistrer un commentaire