Your Question
By using Gorm v2 with Postgres, there is no db.Close() to close the database connection. But it was in Gorm v1, and it is already shown in the new documentation (that sqlite example). The number of connections to database grows as new connections are made. How to close the connection to database using new Gorm v2?
Comment From: petrjahoda
Sorry, my bad, found it here in closed issues.
sqlDB, err := DB.DB() sqlDB.Close()
Better add it somewhere into the documentation.
Comment From: jinzhu
http://v2.gorm.io/docs/generic_interface.html
Comment From: Seb-C
This only works with a single master connection, but when dealing with replicas using DBResolver, it does not close everything since DB.DB() only returns the master connection.
Comment From: makomoriCY
http://v2.gorm.io/docs/generic_interface.html
TY T_T