removed error return value from constructor

This commit is contained in:
Timon Ringwald 2022-07-11 13:05:16 +02:00
parent a39f467b93
commit a1e118f200

13
db.go
View File

@ -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 {