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