add missing error checking to simple example

This commit is contained in:
Stani 2016-04-14 20:56:02 +02:00
parent 37aa7c6f5b
commit ed21175288
1 changed files with 16 additions and 2 deletions

View File

@ -52,9 +52,16 @@ func main() {
for rows.Next() {
var id int
var name string
rows.Scan(&id, &name)
err = rows.Scan(&id, &name)
if err != nil {
log.Fatal(err)
}
fmt.Println(id, name)
}
err = rows.Err()
if err != nil {
log.Fatal(err)
}
stmt, err = db.Prepare("select name from foo where id = ?")
if err != nil {
@ -86,7 +93,14 @@ func main() {
for rows.Next() {
var id int
var name string
rows.Scan(&id, &name)
err = rows.Scan(&id, &name)
if err != nil {
log.Fatal(err)
}
fmt.Println(id, name)
}
err = rows.Err()
if err != nil {
log.Fatal(err)
}
}