Documentation
¶
Overview ¶
Package dbconfig resolves the driver-scoped database connection environment.
Connection variables are namespaced per driver — DB_MYSQL_* and DB_PGSQL_* — and DB_DRIVER selects the active set at runtime. This leaf package lets both internal/platform/database and internal/platform/services/adapter resolve the active connection without an import cycle.
Index ¶
Constants ¶
const ( DriverMySQL = "mysql" DriverMariaDB = "mariadb" DriverPostgres = "postgres" )
Canonical driver names returned by NormalizeDriver and Driver.
Variables ¶
This section is empty.
Functions ¶
func Driver ¶
func Driver() string
Driver returns the active, normalized driver: TEST_DB_DRIVER when set (test runs), else DB_DRIVER, else MySQL.
func Env ¶
Env returns the driver-scoped value of DB_<key>: DB_MYSQL_<key> when the active driver is MySQL/MariaDB, DB_PGSQL_<key> when it is PostgreSQL. Falls back to the legacy flat DB_<key> when the namespaced var is unset, so test targets and scripts that inject flat DB_* credentials keep working.
func EnvDefault ¶
EnvDefault returns Env(key), or def when the driver-scoped value is unset or empty.
func IsPostgres ¶
func IsPostgres() bool
IsPostgres reports whether the active driver is PostgreSQL.
func NormalizeDriver ¶
NormalizeDriver maps a configured driver name to its canonical form: every PostgreSQL alias ("postgres", "postgresql", "pgsql") becomes "postgres"; other values are lower-cased and trimmed ("mysql", "mariadb", ...). An empty value means MySQL. This is the only place driver aliases are known.
Types ¶
This section is empty.