The sql.Rows that you return from your query cannot be used at the same time (I believe).
but you can do most of the heavy lifting in the larynx.
Here is an example (non-working, but close) on Play
package main
import "fmt"
import "sql"
type Row struct {
x string
y string
z string
}
func processor(ch chan Row) {
for row := range <-ch {
}
}
func main() {
ch := make(chan Row)
go processor(ch)
go processor(ch)
rows := db.Query("select x,y,z from whatever")
for rows.Next() {
var row Row
if err := rows.Scan(&row.x, &row.y, &row.z); err != nil {
} else {
ch <- row
}
}
}
source
share