mirror of
https://github.com/TECHNOFAB11/dbmate.git
synced 2026-02-02 09:25:07 +01:00
Set default host based on GOOS
windows: localhost linux: /var/run/postgresql other (incl. macOS): /tmp
This commit is contained in:
parent
8175745cfe
commit
7cc954d8d2
1 changed files with 9 additions and 1 deletions
|
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"net/url"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/amacneil/dbmate/pkg/dbmate"
|
||||
|
|
@ -48,7 +49,14 @@ func connectionString(u *url.URL) string {
|
|||
|
||||
// default hostname
|
||||
if hostname == "" {
|
||||
switch runtime.GOOS {
|
||||
case "windows":
|
||||
hostname = "localhost"
|
||||
case "linux":
|
||||
query.Set("host", "/var/run/postgresql")
|
||||
default:
|
||||
query.Set("host", "/tmp")
|
||||
}
|
||||
}
|
||||
|
||||
// host param overrides url hostname
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue