Skip to content

unix domain socket in URL host position fails with "invalid URL escape" #796

@dhduvall

Description

@dhduvall

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions