package data import ( "database/sql" "fmt" ) var ( pool *sql.DB ) func GetDB() *sql.DB { if pool == nil { // TODO write text panic("") } return pool } func NewDB() (*sql.DB, error) { const ( host = "localhost" user = "admin" pass = "Bambukalo2201" dbname = "subhub" ) dbConnString := fmt.Sprintf("%s:%s@%s/%s?charset=utf8mb4&parseTime=true", user, pass, host, dbname) return sql.Open("mysql", dbConnString) }