defer db connection close

This commit is contained in:
Rodolfo Rodriguez
2017-11-24 22:15:21 -06:00
committed by GitHub
parent e9ca7b3fdf
commit 37a706422c

View File

@@ -39,6 +39,7 @@ The following example shows how to operate on a database based on the `database/
func main() {
db, err := sql.Open("mysql", "astaxie:astaxie@/test?charset=utf8")
defer db.Close()
checkErr(err)
// insert
@@ -93,7 +94,6 @@ The following example shows how to operate on a database based on the `database/
fmt.Println(affect)
db.Close()
}