Merge pull request #296 from stanim/errs
add missing error checks in simple example
This commit is contained in:
commit
aeb3180df5
|
@ -52,9 +52,16 @@ func main() {
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var id int
|
var id int
|
||||||
var name string
|
var name string
|
||||||
rows.Scan(&id, &name)
|
err = rows.Scan(&id, &name)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
fmt.Println(id, name)
|
fmt.Println(id, name)
|
||||||
}
|
}
|
||||||
|
err = rows.Err()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
stmt, err = db.Prepare("select name from foo where id = ?")
|
stmt, err = db.Prepare("select name from foo where id = ?")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -86,7 +93,14 @@ func main() {
|
||||||
for rows.Next() {
|
for rows.Next() {
|
||||||
var id int
|
var id int
|
||||||
var name string
|
var name string
|
||||||
rows.Scan(&id, &name)
|
err = rows.Scan(&id, &name)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
fmt.Println(id, name)
|
fmt.Println(id, name)
|
||||||
}
|
}
|
||||||
|
err = rows.Err()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue