From fe4d2a0501356021ae105cee0ae63cb255906ca5 Mon Sep 17 00:00:00 2001 From: Yanislav Igonin Date: Thu, 26 Aug 2021 17:32:19 +0300 Subject: [PATCH] feat: add env autoload --- config/config.go | 2 +- main.go | 11 +---------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/config/config.go b/config/config.go index 9d61cd1..0902b9e 100644 --- a/config/config.go +++ b/config/config.go @@ -39,7 +39,7 @@ func getAppConfig() AppConfig { func getDbConfig() DbConfig { url := os.Getenv("POSTGRES_URL") if url == "" { - url = "postgresql://localhost/dumpach" + url = "postgresql://localhost/micrach" } return DbConfig{ Url: url, diff --git a/main.go b/main.go index 73b39d1..fc5d641 100644 --- a/main.go +++ b/main.go @@ -5,7 +5,7 @@ import ( "strconv" "github.com/gin-gonic/gin" - "github.com/joho/godotenv" + _ "github.com/joho/godotenv/autoload" Config "micrach/config" // Controllers "micrach/controllers" @@ -14,18 +14,9 @@ import ( ) func main() { - err := godotenv.Load(".env") - if err != nil { - log.Panicln(err) - } - Config.Init() Db.Init() defer Db.Pool.Close() - // err = Utils.CreateUploadsFolder() - if err != nil { - log.Panicln(err) - } gin.SetMode(Config.App.Env) router := gin.Default()