go-api-pkg/config/config.go
2024-05-30 17:19:16 +02:00

24 lines
328 B
Go

package config
import (
"os"
"github.com/gofiber/fiber/v2/log"
"github.com/joho/godotenv"
)
var ErrLoadingEnvs error
func init() {
ErrLoadingEnvs = godotenv.Load()
}
func GetEnv(name string, defVal string) string {
env := os.Getenv(name)
if env == "" {
log.Panicf("Missing %s env variable", name)
}
return env
}