由于我没有在 *gorm 实例的 Close() 函数中找到,任何帮助将不胜感激
dbURI := fmt.Sprintf("user=%s password=%s dbname=%s port=%s sslmode=%s TimeZone=%s",
"username", "password", "dbname", "5432", "disable", "Asia/Kolkata")
fmt.Println(dbURI)
connection, err := gorm.Open(postgres.Open(dbURI), &gorm.Config{})
if err != nil {
fmt.Println("Error connecting database")
panic(err.Error())
} else {
fmt.Println("Connected to database")
}
注意:connection.Close() 不适用于 GORM 1.20.0