package bd import ( "database/sql" _ "github.com/lib/pq" ) type Bd struct { config *ConfigBD db *sql.DB } func New(config *ConfigBD) *Bd { return &Bd{ config: config, } } func (b *Bd) Open() error { db, err := sql.Open("postgres", b.config.BaseUrlBd) if err != nil { return err } if err := db.Ping(); err != nil { return err } b.db = db return nil } func (b *Bd) Close() { b.db.Close() }