Skip to content

Instantly share code, notes, and snippets.

@aodin
Created December 16, 2016 18:06
Show Gist options
  • Save aodin/b11b8251c08350ed3b7f495fb78a7358 to your computer and use it in GitHub Desktop.
Save aodin/b11b8251c08350ed3b7f495fb78a7358 to your computer and use it in GitHub Desktop.
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