clessy-ng/utils/env.go
Hamcha 42de49b13d
Some checks failed
continuous-integration/drone/push Build is failing
Use db not files!
2022-03-25 20:06:13 +01:00

25 lines
405 B
Go

package utils
import (
"log"
"os"
)
func RequireEnv(name string) string {
val, ok := os.LookupEnv(name)
if !ok {
log.Fatalf("FATAL: Required env var %s is missing", name)
}
if val == "" {
log.Fatalf("FATAL: Required env var %s is empty", name)
}
return val
}
func EnvFallback(name string, fallback string) string {
val := os.Getenv(name)
if val == "" {
return fallback
}
return val
}