From a1e118f200b9efe002fa011c0ab9f68f20f279da Mon Sep 17 00:00:00 2001 From: Timon Ringwald Date: Mon, 11 Jul 2022 13:05:16 +0200 Subject: [PATCH] removed error return value from constructor --- db.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) 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 {