package database import ( _ "github.com/go-sql-driver/mysql" "github.com/jmoiron/sqlx" ) type Database struct { db *sqlx.DB } func New(dns string) (*Database, error) { db, err := sqlx.Open("mysql", dns) if err != nil { return nil, err } if err := db.Ping(); err != nil { return nil, err } return &Database{db: db}, nil }