From dde86429453dc36322a79e802212f2c85fda2db5 Mon Sep 17 00:00:00 2001 From: Elias Braun Date: Wed, 5 Jun 2024 01:10:22 +0200 Subject: [PATCH] Fixed config issue --- src/config/config.go | 52 +++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/src/config/config.go b/src/config/config.go index 2adab70..fd917f0 100644 --- a/src/config/config.go +++ b/src/config/config.go @@ -1,8 +1,6 @@ package config import ( - "encoding/json" - "log" "os" ) @@ -23,34 +21,34 @@ type CFG struct { ProjectName string `json:"Project"` } -// func GetConfig() *CFG { -// var c CFG -// c.DB.Host = "db" -// c.DB.Port = 5432 -// c.DB.Username = os.Getenv("DBUser") -// c.DB.Password = os.Getenv("DBPassword") -// c.DB.Database = os.Getenv("Database") -// c.Website.Host = "0.0.0.0" -// c.Website.Port = 80 -// c.ProjectName = os.Getenv("ProjectName") - -// return &c -// } +func GetConfig() *CFG { + var c CFG + c.DB.Host = "db" + c.DB.Port = 5432 + c.DB.Username = os.Getenv("DBUser") + c.DB.Password = os.Getenv("DBPassword") + c.DB.Database = os.Getenv("Database") + c.Website.Host = "0.0.0.0" + c.Website.Port = 80 + c.ProjectName = os.Getenv("ProjectName") + + return &c +} // Enable for local testing without docker container -func GetConfig() *CFG { - const file = "config/config.json" - var config CFG +// func GetConfig() *CFG { +// const file = "config/config.json" +// var config CFG - cfgfile, err := os.Open(file) - if err != nil { - log.SetFlags(log.LstdFlags | log.Lshortfile) - log.Fatalf("Error readeing config file: %d\n", err) - } +// cfgfile, err := os.Open(file) +// if err != nil { +// log.SetFlags(log.LstdFlags | log.Lshortfile) +// log.Fatalf("Error readeing config file: %d\n", err) +// } - jsonParser := json.NewDecoder(cfgfile) - jsonParser.Decode(&config) +// jsonParser := json.NewDecoder(cfgfile) +// jsonParser.Decode(&config) - return &config -} +// return &config +// }