package pq

import (
	
	
	
	
	
	
)
Connector represents a fixed configuration for the pq driver with a given name. Connector satisfies the database/sql/driver Connector interface and can be used to create any number of DB Conn's via the database/sql OpenDB function. See https://golang.org/pkg/database/sql/driver/#Connector. See https://golang.org/pkg/database/sql/#OpenDB.
type Connector struct {
	opts   values
	dialer Dialer
}
Connect returns a connection to the database using the fixed configuration of this Connector. Context is not used.
func ( *Connector) ( context.Context) (driver.Conn, error) {
	return .open()
}
Driver returnst the underlying driver of this Connector.
func ( *Connector) () driver.Driver {
	return &Driver{}
}
NewConnector returns a connector for the pq driver in a fixed configuration with the given dsn. The returned connector can be used to create any number of equivalent Conn's. The returned connector is intended to be used with database/sql.OpenDB. See https://golang.org/pkg/database/sql/driver/#Connector. See https://golang.org/pkg/database/sql/#OpenDB.
func ( string) (*Connector, error) {
	var  error
	 := make(values)
A number of defaults are applied here, in this order: * Very low precedence defaults applied in every situation * Environment variables * Explicitly passed connection information
	["host"] = "localhost"
N.B.: Extra float digits should be set to 3, but that breaks Postgres 8.4 and older, where the max is 2.
	["extra_float_digits"] = "2"
	for ,  := range parseEnviron(os.Environ()) {
		[] = 
	}

	if strings.HasPrefix(, "postgres://") || strings.HasPrefix(, "postgresql://") {
		,  = ParseURL()
		if  != nil {
			return nil, 
		}
	}

	if  := parseOpts(, );  != nil {
		return nil, 
	}
Use the "fallback" application name if necessary
	if ,  := ["fallback_application_name"];  {
		if ,  := ["application_name"]; ! {
			["application_name"] = 
		}
	}
We can't work with any client_encoding other than UTF-8 currently. However, we have historically allowed the user to set it to UTF-8 explicitly, and there's no reason to break such programs, so allow that. Note that the "options" setting could also set client_encoding, but parsing its value is not worth it. Instead, we always explicitly send client_encoding as a separate run-time parameter, which should override anything set in options.
	if ,  := ["client_encoding"];  && !isUTF8() {
		return nil, errors.New("client_encoding must be absent or 'UTF8'")
	}
DateStyle needs a similar treatment.
	if ,  := ["datestyle"];  {
		if  != "ISO, MDY" {
			return nil, fmt.Errorf("setting datestyle must be absent or %v; got %v", "ISO, MDY", )
		}
	} else {
		["datestyle"] = "ISO, MDY"
	}
If a user is not provided by any other means, the last resort is to use the current operating system provided user name.
	if ,  := ["user"]; ! {
		,  := userCurrent()
		if  != nil {
			return nil, 
		}
		["user"] = 
	}

	return &Connector{opts: , dialer: defaultDialer{}}, nil