Both of them work and as far as I know there is not real difference between them.
import "database/sql"
import _ "github.com/lib/pq"
connStr := fmt.Sprintf("postgres://%s:%s@localhost/%s?sslmode=disable", user, password, dbName)
db, err := sql.Open("postgres", connStr)
///////////////////////////////
import "database/sql"
import _ "github.com/lib/pq"
connStr := fmt.Sprintf("user=%s password=%s dbname=%s sslmode=disable", user, password, dbName)
db, err := sql.Open("postgres", connStr)
if err != nil {
log.Fatal(err)
}
More info you can find here: https://godoc.org/github.com/lib/pq