ebf246beb0
- 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>
17 lines
392 B
Go
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
|
|
}
|