package db import ( "git.minhas.io/asara/gologger" "git.minhas.io/asara/well-goknown/config" "github.com/jmoiron/sqlx" _ "github.com/lib/pq" ) func NewDB() (*sqlx.DB, error) { l := gologger.Get(config.GetConfig().LogLevel).With().Str("context", "db").Logger() db, err := sqlx.Open("postgres", config.GetConfig().DbUrl) if err != nil { l.Panic().Msg(err.Error()) } err = db.Ping() if err != nil { l.Panic().Msg(err.Error()) } l.Debug().Msg("connected to database") return db, nil }