Files
query-orchestration/internal/env/get.go
T

26 lines
366 B
Go
Raw Normal View History

2024-12-18 18:54:48 +00:00
package env
import (
"fmt"
2024-12-18 18:54:48 +00:00
"log"
"os"
)
2024-12-24 18:11:25 +00:00
func GetPanic(name string) string {
value, err := Get(name)
if err != nil {
log.Panic(err.Error())
2024-12-18 18:54:48 +00:00
}
return value
}
func Get(name string) (string, error) {
2024-12-18 18:54:48 +00:00
value, exists := os.LookupEnv(name)
if !exists || value == "" {
return "", fmt.Errorf("environment variable not set: %s", name)
2024-12-18 18:54:48 +00:00
}
return value, nil
2024-12-18 18:54:48 +00:00
}