package db import ( "database/sql" "errors" "net/url" _ "github.com/lib/pq" "github.com/volker-raschek/go-logger/pkg/logger" ) var ( errorUnsupportedDatabase = errors.New("Unsupported database scheme") flogger = logger.NewSilentLogger() ) func New(storageEndpoint *url.URL) (Database, error) { switch storageEndpoint.Scheme { case "postgres": newDBO, err := sql.Open(storageEndpoint.Scheme, storageEndpoint.String()) if err != nil { return nil, err } return &Postgres{ dbo: newDBO, }, nil default: return nil, errorUnsupportedDatabase } } func SetLogger(logger logger.Logger) { flogger = logger }