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 in URL host position fails with "invalid URL escape" #796

Open
dhduvall opened this issue Oct 8, 2018 · 1 comment
Open

Comments

@dhduvall
Copy link

dhduvall commented Oct 8, 2018

If I try to ping a database with the URL

postgresql://%2Fvar%2Flib%2Fpostgresql/dbname

as described in the Postgres manual section "Connection Strings", I get the following error message:

parse postgresql://%2Fvar%2Flib%2Fpostgresql/dbname: invalid URL escape "%2F"

This is the same error you get if use use the Parse() method from net/url on that string.

Here's the complete program:

package main

import (
        "database/sql"
        "fmt"

        _ "github.com/lib/pq"
)

func main() {
        connStr := `postgresql://%2Fvar%2Flib%2Fpostgresql/dbname`
        db, _ := sql.Open("postgres", connStr)
        err := db.Ping()
        fmt.Println(err)
}

It all works fine if I put the "host" in the query string (?host=/var/lib/postgresql).

@Moulick
Copy link

Moulick commented Feb 3, 2024

Can we please give this issue some love 😄

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