Files
llink/go/internal/utils/env.go
T
Arjun Patel 563c91e7d5 infra: add logging wrapping
Resolves issues with gcp cloud logging quirks such as field names
2026-05-27 15:49:27 -07:00

34 lines
715 B
Go

package utils
import (
"os"
"github.com/flowy-live/llink/internal/utils/flog"
)
// EnvVar enumerates the env vars referenced via this package.
type EnvVar string
const ()
// MustGetEnv panics if the variable is unset.
func MustGetEnv[T string | EnvVar](key T) string {
keyString := string(key)
value := os.Getenv(keyString)
if value == "" {
flog.Error("missing required environment variable", "key", key)
panic("Missing required environment variable")
}
return value
}
// GetEnv returns "" if the variable is unset (and logs a warning).
func GetEnv(key string) string {
value := os.Getenv(key)
if value == "" {
flog.Warn("missing optional environment variable", "key", key)
}
return value
}