https://github.com/joegasewicz/pg-conf
Sets Postgres environment variables to a config type
https://github.com/joegasewicz/pg-conf
config pgconfig postgres
Last synced: 5 days ago
JSON representation
Sets Postgres environment variables to a config type
- Host: GitHub
- URL: https://github.com/joegasewicz/pg-conf
- Owner: joegasewicz
- License: mit
- Created: 2022-11-03T18:42:43.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-11-03T22:26:50.000Z (almost 3 years ago)
- Last Synced: 2025-02-10T14:53:20.092Z (8 months ago)
- Topics: config, pgconfig, postgres
- Language: Go
- Homepage:
- Size: 10.7 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PG Conf
Sets Postgres environment variables to a config typeEnvironment variables will override defaults set on `PostgresConfig`, making it simple for creating a local default config.
### Example
```go
os.Setenv("PGHOST", "www.google.com")
os.Setenv("PGUSER", "John")
os.Setenv("PGPASSWORD", "wizard")
os.Setenv("PGDATABASE", "happy_db")
os.Setenv("PGPORT", "1234")
os.Setenv("PGSSLMODE", "verify-ca")type Config struct {
*pg_conf.PostgresConfig
}cfg := Config{
PostgresConfig: &PostgresConfig{
// Add defaults here if requires... (env vars will override defaults)
},
}pg_conf.Update(cfg.PostgresConfig)
connStr := cfg.PostgresConfig.GetPostgresConnStr()
// result - "host=www.google.com user=John dbname=happy_db password=wizard port=1234 sslmode=verify-ca"
```