removed explicit "end" functions and turned them into functions returned by setup

This commit is contained in:
2025-10-04 13:32:47 -06:00
parent 3ef8d6b9a6
commit 445f50a5c0
3 changed files with 14 additions and 19 deletions
+5 -8
View File
@@ -15,20 +15,17 @@ import (
"github.com/jmoiron/sqlx"
)
// amdb is the reference to the Amsterdam database.
// amdb is the reference to the Amsterdam database. Returns a function to close it down.
var amdb *sqlx.DB
// SetupDb sets up the database and associated items.
func SetupDb() error {
func SetupDb() (func(), error) {
db, err := sqlx.Open(config.GlobalConfig.Database.Driver, config.GlobalConfig.Database.Dsn)
if err == nil {
amdb = db
// TODO: additional initialization
}
return err
}
// ClosedownDb closes down the database and associated items.
func ClosedownDb() {
amdb.Close()
return func() {
amdb.Close()
}, err
}