mirror of
https://github.com/TECHNOFAB11/dbmate.git
synced 2026-02-02 17:35:08 +01:00
Default to localhost if not linux or BSD
This commit is contained in:
parent
0fd7f79820
commit
cf59ceac74
2 changed files with 6 additions and 6 deletions
|
|
@ -50,12 +50,12 @@ func connectionString(u *url.URL) string {
|
||||||
// default hostname
|
// default hostname
|
||||||
if hostname == "" {
|
if hostname == "" {
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
case "windows":
|
|
||||||
hostname = "localhost"
|
|
||||||
case "linux":
|
case "linux":
|
||||||
query.Set("host", "/var/run/postgresql")
|
query.Set("host", "/var/run/postgresql")
|
||||||
default:
|
case "darwin", "freebsd", "dragonfly", "openbsd", "netbsd":
|
||||||
query.Set("host", "/tmp")
|
query.Set("host", "/tmp")
|
||||||
|
default:
|
||||||
|
hostname = "localhost"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,12 +53,12 @@ func TestGetDriver(t *testing.T) {
|
||||||
|
|
||||||
func defaultConnString() string {
|
func defaultConnString() string {
|
||||||
switch runtime.GOOS {
|
switch runtime.GOOS {
|
||||||
case "windows":
|
|
||||||
return "postgres://localhost:5432/foo"
|
|
||||||
case "linux":
|
case "linux":
|
||||||
return "postgres://:5432/foo?host=%2Fvar%2Frun%2Fpostgresql"
|
return "postgres://:5432/foo?host=%2Fvar%2Frun%2Fpostgresql"
|
||||||
default:
|
case "darwin", "freebsd", "dragonfly", "openbsd", "netbsd":
|
||||||
return "postgres://:5432/foo?host=%2Ftmp"
|
return "postgres://:5432/foo?host=%2Ftmp"
|
||||||
|
default:
|
||||||
|
return "postgres://localhost:5432/foo"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue