diff --git a/db.go b/db.go index 85795c2..9bc5907 100644 --- a/db.go +++ b/db.go @@ -3,7 +3,6 @@ package advsql import ( "database/sql" - "git.tordarus.net/Tordarus/adverr" _ "github.com/go-sql-driver/mysql" ) @@ -19,21 +18,21 @@ func NewDatabase(conn *sql.DB) *Database { } } -func NewMysqlDatabase(host string, port uint16, user, pass, db string) (*Database, error) { +func NewMysqlDatabase(host string, port uint16, user, pass, db string) *Database { conn, err := sql.Open("mysql", connString(host, port, user, pass, db)) if err != nil { - return nil, adverr.Wrap("could not connect to database", err) + panic(err) } - return NewDatabase(conn), nil + return NewDatabase(conn) } -func (db *Database) prepare(query string) (*sql.Stmt, error) { +func (db *Database) prepare(query string) *sql.Stmt { s, err := db.db.Prepare(query) if err != nil { - return nil, err + panic(err) } db.closefuncs = append(db.closefuncs, s.Close) - return s, nil + return s } func (db *Database) Close() error {