Documentation
¶
Overview ¶
Package pg supplies the standard libpq PG* flag set and the connection Config it binds. Consumers embed Config in a command config, list Binder{Config: &cfg}.Flags() in the command's flags, and pass Config.ConnString() to their PostgreSQL driver; empty fields are omitted so the driver falls back to the PG* environment variables (and ~/.pgpass / ~/.pg_service.conf). Opening a pool stays with the consumer.
Index ¶
Constants ¶
const ( HostFlag = "pghost" PortFlag = "pgport" DatabaseFlag = "pgdatabase" UserFlag = "pguser" PasswordFlag = "pgpassword" SSLModeFlag = "pgsslmode" )
PG* flag names (constants for reuse in tests/help).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Binder ¶
type Binder struct {
Config *Config
}
Binder binds the standard libpq-compatible PG* flags to a shared Config. The destination pointer lives in a field (not a parameter) so the binder itself travels by value while the flags still write into the one Config instance the command's action reads — the same binder pattern as app.LoggerFlags.
type Config ¶
type Config struct {
Host host
Name name
User user
Password password
SSLMode sslMode
Port port
}
Config holds libpq-compatible PostgreSQL connection parameters, bound from the standard PG* flags. Fields are exported because the CLI binds them by pointer; the field types are unexported domain types (see types.go).
func (Config) ConnString ¶
ConnString constructs a libpq KV connection string from the explicit flag values. Empty fields are omitted so the driver falls back to the PG* environment variables (and ~/.pgpass / ~/.pg_service.conf).