package db import ( "database/sql" "errors" "fmt" "git.faercol.me/faercol/polyculeconnect/polyculeconnect/config" ) type concreteDBService struct { } func connectSQLite(path string) (*sql.DB, error) { return sql.Open("sqlite3", path) } func Connect(conf *config.AppConfig) (*sql.DB, error) { switch conf.StorageType { case string(config.Memory): return nil, errors.New("no db for memory mode") case string(config.SQLite): return connectSQLite(conf.StorageConfig.File) default: return nil, fmt.Errorf("unsupported storage mode %q", conf.StorageType) } }