go-api-pkg/config/config.go

24 lines
328 B
Go
Raw Normal View History

2023-06-21 20:38:30 +02:00
package config
import (
"os"
2024-05-30 17:19:16 +02:00
"github.com/gofiber/fiber/v2/log"
2023-06-21 20:38:30 +02:00
"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 == "" {
2024-05-30 17:19:16 +02:00
log.Panicf("Missing %s env variable", name)
2023-06-21 20:38:30 +02:00
}
return env
}