go-cook-portal/services/config.go

29 lines
397 B
Go
Raw Normal View History

2024-04-09 07:29:45 -07:00
package services
import (
"log"
"os"
"github.com/joho/godotenv"
)
type EnvConfig struct {
ApiServerUri string
CookieSecret string
}
func NewEnvConfig() EnvConfig {
_, err := os.Stat(".env")
if err == nil {
err = godotenv.Load()
if err != nil {
log.Println(err)
}
2024-04-09 07:29:45 -07:00
}
return EnvConfig{
ApiServerUri: os.Getenv("ApiServerUri"),
CookieSecret: os.Getenv("CookieSecret"),
}
}