feat: add env autoload

This commit is contained in:
Yanislav Igonin 2021-08-26 17:32:19 +03:00
parent 843e81dd78
commit fe4d2a0501
2 changed files with 2 additions and 11 deletions

View File

@ -39,7 +39,7 @@ func getAppConfig() AppConfig {
func getDbConfig() DbConfig { func getDbConfig() DbConfig {
url := os.Getenv("POSTGRES_URL") url := os.Getenv("POSTGRES_URL")
if url == "" { if url == "" {
url = "postgresql://localhost/dumpach" url = "postgresql://localhost/micrach"
} }
return DbConfig{ return DbConfig{
Url: url, Url: url,

11
main.go
View File

@ -5,7 +5,7 @@ import (
"strconv" "strconv"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/joho/godotenv" _ "github.com/joho/godotenv/autoload"
Config "micrach/config" Config "micrach/config"
// Controllers "micrach/controllers" // Controllers "micrach/controllers"
@ -14,18 +14,9 @@ import (
) )
func main() { func main() {
err := godotenv.Load(".env")
if err != nil {
log.Panicln(err)
}
Config.Init() Config.Init()
Db.Init() Db.Init()
defer Db.Pool.Close() defer Db.Pool.Close()
// err = Utils.CreateUploadsFolder()
if err != nil {
log.Panicln(err)
}
gin.SetMode(Config.App.Env) gin.SetMode(Config.App.Env)
router := gin.Default() router := gin.Default()