func InitDatabase(driver, dbPath string) error {
var db gorm.DB
var err error
switch driver {
case "sqlite3":
db, err = gorm.Open("sqlite3", dbPath)
if err != nil {
return err
}
break
case "mysql":
db, err = gorm.Open("mysql", dbPath)
if err != nil {
return err
}
break
case "postgres":
db, err = gorm.Open("postgres", dbPath)
if err != nil {
return err
}
break
default:
return fmt.Errorf("Unknown database driver of %v", driver)
}