diff options
| author | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2022-10-26 01:04:11 +0300 |
|---|---|---|
| committer | Arda Serdar Pektezol <1669855+pektezol@users.noreply.github.com> | 2022-10-26 01:04:11 +0300 |
| commit | 5c4246dae97d128e0af41d0e59fbdf51ec4452ad (patch) | |
| tree | 35cd19fb48390aa496565c7fed2306c774c1eced /backend/database | |
| parent | load .env once on main (diff) | |
| download | lphub-5c4246dae97d128e0af41d0e59fbdf51ec4452ad.tar.gz lphub-5c4246dae97d128e0af41d0e59fbdf51ec4452ad.tar.bz2 lphub-5c4246dae97d128e0af41d0e59fbdf51ec4452ad.zip | |
change env key retrieve method
Diffstat (limited to 'backend/database')
| -rw-r--r-- | backend/database/database.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/backend/database/database.go b/backend/database/database.go index 85ebaa2..5a55c21 100644 --- a/backend/database/database.go +++ b/backend/database/database.go | |||
| @@ -3,19 +3,19 @@ package database | |||
| 3 | import ( | 3 | import ( |
| 4 | "database/sql" | 4 | "database/sql" |
| 5 | "fmt" | 5 | "fmt" |
| 6 | "os" | ||
| 6 | 7 | ||
| 7 | _ "github.com/lib/pq" | 8 | _ "github.com/lib/pq" |
| 8 | "github.com/pektezol/leastportals/backend/controllers" | ||
| 9 | ) | 9 | ) |
| 10 | 10 | ||
| 11 | var DB *sql.DB | 11 | var DB *sql.DB |
| 12 | 12 | ||
| 13 | func ConnectDB() { | 13 | func ConnectDB() { |
| 14 | host := controllers.GetEnvKey("DB_HOST") | 14 | host := os.Getenv("DB_HOST") |
| 15 | port := controllers.GetEnvKey("DB_PORT") | 15 | port := os.Getenv("DB_PORT") |
| 16 | user := controllers.GetEnvKey("DB_USER") | 16 | user := os.Getenv("DB_USER") |
| 17 | pass := controllers.GetEnvKey("DB_PASS") | 17 | pass := os.Getenv("DB_PASS") |
| 18 | name := controllers.GetEnvKey("DB_NAME") | 18 | name := os.Getenv("DB_NAME") |
| 19 | psqlInfo := fmt.Sprintf("host=%s port=%s user=%s "+ | 19 | psqlInfo := fmt.Sprintf("host=%s port=%s user=%s "+ |
| 20 | "password=%s dbname=%s sslmode=disable", | 20 | "password=%s dbname=%s sslmode=disable", |
| 21 | host, port, user, pass, name) | 21 | host, port, user, pass, name) |