fix goroutine leak while calling db.Ping() error

This commit is contained in:
cloudaice 2016-09-18 14:26:16 +08:00
parent 041cd3dd31
commit 7dcd80ddf9
1 changed files with 3 additions and 0 deletions

View File

@ -75,6 +75,9 @@ func Open(dialect string, args ...interface{}) (*DB, error) {
if err == nil {
err = db.DB().Ping() // Send a ping to make sure the database connection is alive.
if err != nil {
db.DB().Close()
}
}
}