Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DSNREnvRegex = regexp.MustCompile(`\$\{([A-Za-z0-9_]+)\}`)
Functions ¶
func AuthError ¶ added in v0.5.15
AuthError wraps err in an Unauthenticated gRPC status naming the failing database when err is a database auth failure, or returns nil otherwise, preserving the original error via errors.As. Detection covers SQLSTATE class 28 (Postgres/Redshift), MySQL error 1045, and DB2 (db2.IsAuthError); drivers without any of these (Vertica, Oracle, MSSQL, SAP HDB) fall through to a generic ping error.
func ResolveDatabaseName ¶ added in v0.5.5
func ResolveDatabaseName(opts ConnectOptions) string
ResolveDatabaseName returns the database opts would connect to, merging the DSN path with the structured field. Empty when neither supplies one.
Types ¶
type ConnectOptions ¶ added in v0.4.0
type ConnectOptions struct {
DSN string
Scheme string
Host string
Port string
Database string
User string
Password string
Params map[string]string
// Lookup resolves ${KEY} placeholders. When nil, os.LookupEnv is used.
Lookup LookupFunc
}
ConnectOptions represents the structured configuration used to build a DSN. Any field may include ${ENV_VAR} placeholders that will be expanded before use.
type LookupFunc ¶ added in v0.5.12
LookupFunc resolves ${KEY} placeholders during DSN/connect field expansion. When nil is passed to expand helpers, os.LookupEnv is used (CLI compatibility). Library embedders should pass a map-backed LookupFunc and never mutate process env.