Skip to content

Commit

Permalink
[#4] call db.Close() on MustOpen() failure
Browse files Browse the repository at this point in the history
  • Loading branch information
afriza authored Aug 17, 2023
1 parent f9efbf6 commit 2d3b72b
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ func MustOpen(driverName, dsn string) (*DB, error) {
return nil, err
}
if err := db.sqlDB.Ping(); err != nil {
db.Close()
return nil, err
}
return db, nil
Expand Down

0 comments on commit 2d3b72b

Please sign in to comment.