Files
fn_registry/functions/infra/env_require.go
T
egutierrez ebf246beb0 feat(infra): funciones impuras Go para carga de env/config (dotenv, env_require, config_from_env, config_from_file)
- dotenv_load: parser .env con no-sobreescritura y soporte de comillas
- env_require: os.Getenv con error descriptivo fail-fast
- env_require_all: verifica multiples vars y lista todas las faltantes
- config_from_env: reflection sobre struct tags env/default/required/secret, 5 tipos soportados
- config_from_file: JSON via stdlib, YAML stub con not-implemented
- 25 tests unitarios, todos PASS

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-13 02:01:50 +02:00

17 lines
392 B
Go

package infra
import (
"fmt"
"os"
)
// EnvRequire returns the value of the environment variable named key.
// If the variable is unset or empty it returns an error with a descriptive message.
func EnvRequire(key string) (string, error) {
val := os.Getenv(key)
if val == "" {
return "", fmt.Errorf("env_require: environment variable %q is not set or empty", key)
}
return val, nil
}