From 2d3b72b5127243ab9e84070c6d1a5436956b865b Mon Sep 17 00:00:00 2001 From: "Afriza N. Arief" Date: Thu, 17 Aug 2023 15:02:44 +0700 Subject: [PATCH] [#4] call db.Close() on MustOpen() failure --- db.go | 1 + 1 file changed, 1 insertion(+) diff --git a/db.go b/db.go index 11aa1f5..b46f1d5 100644 --- a/db.go +++ b/db.go @@ -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