How do I pass my driver type and driver source to a function that initialize a database connection using an ODBC adator.
Do I need the Driver struct for anything?
Can anybody please help in clarifying how and what to do to create a function that realize my aforementioned purpose.
import (
"database/sql"
_"github.com/alexbrainman/odbc"
)
type Driver struct {
// Stats
// contains filtered or unexported fields
}
func (d *Driver) InitialiseDBConnection(driverType, driverSourceName string) {
db, err := sql.Open(driverType, driverSourceNam)
if err != nil {
panic(err.Error())
}
err = db.Ping()
if err != nil {
panic(err.Error())
}
defer db.Close()
}
Do I need a Driver Struct to contain a list of acceptable drivers or the underlined type of driver is passed from the function arguments?
Thanks