Skip to content

Instantly share code, notes, and snippets.

@aodin aodin/sql_results.go
Created Dec 16, 2016

Embed
What would you like to do?
Go's SQL Results Must Be Closed
package main
import "database/sql"
import "log"
import _ "github.com/lib/pq"
func main() {
conn, err := sql.Open("postgres", "user=aaronoellis dbname=bar sslmode=disable")
if err != nil {
log.Fatal(err)
}
for i := 0; i < 101; i += 1 {
rows, err := conn.Exec("select * from items")
if err != nil {
log.Fatal(err)
}
log.Println(rows)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.