go-cook-portal/services/config.go

31 lines
482 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
SharedApiSecret string
CookieSecret string
2024-04-09 07:29:45 -07:00
}
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"),
SharedApiSecret: os.Getenv("SharedApiSecret"),
CookieSecret: os.Getenv("CookieSecret"),
2024-04-09 07:29:45 -07:00
}
}