Skip to content

Commit

Permalink
add missing error checking to simple example
Browse files Browse the repository at this point in the history
  • Loading branch information
stanim committed Apr 14, 2016
1 parent 37aa7c6 commit ed21175
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions _example/simple/simple.go
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}
}

0 comments on commit ed21175

Please sign in to comment.