Created
December 16, 2016 18:06
-
-
Save aodin/b11b8251c08350ed3b7f495fb78a7358 to your computer and use it in GitHub Desktop.
Go's SQL Results Must Be Closed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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