github.com/yandex/pandora@v0.5.32/lib/confutil/env_var_resolver.go (about) 1 package confutil 2 3 import ( 4 "errors" 5 "fmt" 6 "os" 7 ) 8 9 var ErrEnvVariableNotProvided error = errors.New("env variable not set") 10 11 // Resolve custom tag token with env variable value 12 var EnvTagResolver TagResolver = envTokenResolver 13 14 func envTokenResolver(in string) (string, error) { 15 // TODO: windows os is case-insensitive for env variables, 16 // so it may requre to load all vars and lookup for env var manually 17 18 val, ok := os.LookupEnv(in) 19 if !ok { 20 return "", fmt.Errorf("%s: %w", in, ErrEnvVariableNotProvided) 21 } 22 23 return val, nil 24 }