Skip to content

Commit b819467

Browse files
lnkszmattn
authored andcommitted
Add error checking in simple example for tx.Commit
Based on https://golang.org/pkg/database/sql/#Tx.Commit this function returns an error type. So why not check it.
1 parent 43dcd31 commit b819467

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

_example/simple/simple.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ func main() {
4242
log.Fatal(err)
4343
}
4444
}
45-
tx.Commit()
45+
err = tx.Commit()
46+
if err != nil {
47+
log.Fatal(err)
48+
}
4649

4750
rows, err := db.Query("select id, name from foo")
4851
if err != nil {

0 commit comments

Comments
 (0)