pgconn

package
v1.1.0-beta.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2026 License: ISC Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnConfig

type ConnConfig struct {
	Host     string
	Port     string
	Username string
	Password string

	SSLMode     string // disable, allow, prefer, require, verify-ca, verify-full
	SSLCert     string // path to client certificate file (PEM)
	SSLKey      string // path to client private key file (PEM)
	SSLRootCert string // path to root CA certificate file (PEM)
}

ConnConfig holds the connection parameters shared by all PostgreSQL connectors.

func ParseConnConfig

func ParseConnConfig(config map[string]string) (ConnConfig, string, error)

ParseConnConfig parses host, port, username, and password from the "location" URI and from standalone config keys. Standalone keys override URI components. The path component of the URI (i.e. the database name) is returned separately so callers can handle it as appropriate (use it, reject it, or ignore it).

func (ConnConfig) Args

func (c ConnConfig) Args() []string

Args returns the common connection flags shared by all PostgreSQL client tools: -h host -p port -w, plus -U username when one is configured.

func (ConnConfig) Env

func (c ConnConfig) Env() []string

Env returns the current process environment with PostgreSQL authentication and TLS variables injected when configured.

func (ConnConfig) Ping

func (c ConnConfig) Ping(ctx context.Context, psqlBin, connectDB string) error

Ping verifies connectivity by running SELECT 1 against the server. If connectDB is empty, "postgres" is used.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL