c3b007a4e7
- ConfigError y ConfigValidation como tipos producto con sus .md en types/infra/ - config_validate: validacion con tags required/format/min/max/oneof via reflection - config_merge: merge no-mutante de map[string]string con precedencia de override - config_dump: serializacion de structs a map con mascara *** para campos secret - 17 tests unitarios, todos PASS Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1.5 KiB
1.5 KiB
name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
| name | kind | lang | domain | version | purity | signature | description | tags | uses_functions | uses_types | returns | returns_optional | error_type | imports | params | output | tested | tests | test_file_path | file_path | |||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| config_merge | function | go | infra | 1.0.0 | pure | func ConfigMerge(base, override map[string]string) map[string]string | Merge de dos map[string]string. El map override tiene precedencia sobre base en claves comunes. Ninguno de los inputs es mutado — retorna un mapa nuevo. |
|
false |
|
nuevo mapa con todas las claves de base y override, donde override gana en conflictos | true |
|
functions/infra/config_merge_test.go | functions/infra/config_merge.go |
Ejemplo
defaults := map[string]string{"host": "localhost", "port": "5432", "debug": "false"}
env := map[string]string{"port": "9999", "debug": "true"}
merged := ConfigMerge(defaults, env)
// merged = {"host": "localhost", "port": "9999", "debug": "true"}
Notas
Funcion pura. Util para combinar defaults hardcodeados con valores del archivo .env o de variables de entorno. Patron tipico: ConfigMerge(hardcoded_defaults, dotenv_values).