Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unix domain socket is sometimes in other locations than /var/run/postgresql/ #131

Closed
drt24 opened this issue Mar 21, 2016 · 3 comments
Closed

Comments

@drt24
Copy link

drt24 commented Mar 21, 2016

https://github.com/go-pg/pg/blob/v4/options.go#L69 has:

if opt.getNetwork() == "unix" {
    return "/var/run/postgresql/.s.PGSQL.5432"
}

However on my (freebsd) system .s.PGSQL.5432 is in /tmp/ which with the standard sql connector I can work with by using sql.Open("postgres", "dbname=history.db sslmode=disable host=/tmp/") but that doesn't work with this library as the parth is hard coded.

@vmihailenco
Copy link
Member

Try this:

db := pg.Connect(&pg.Options{
    Network: "unix",
    Addr: "/tmp/.s.PGSQL.5432",
})

@drt24
Copy link
Author

drt24 commented Mar 22, 2016

Ahh I am blind. Thank you.

@vmihailenco
Copy link
Member

Np. We just need a comment on Addr string field...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants