Let people connect with just a hostname

This commit is contained in:
Jake Sanders 2019-11-01 15:16:05 +00:00
parent ee35fe61af
commit 15e3b9b4c0

View File

@ -4,6 +4,7 @@ package postgresql
import ( import (
"database/sql" "database/sql"
"fmt" "fmt"
"strings"
"time" "time"
"unicode" "unicode"
@ -192,6 +193,9 @@ func New(opts ...options.Option) (store.Store, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
if !strings.Contains(dataSourceName, " ") {
dataSourceName = fmt.Sprintf("host=%s", dataSourceName)
}
db, err := sql.Open(driver, dataSourceName) db, err := sql.Open(driver, dataSourceName)
if err != nil { if err != nil {
return nil, err return nil, err