Inner map on structs are not considered when unmarshalling with viper_bind_struct tag #1800
Open
3 tasks done
Labels
kind/bug
Something isn't working
Preflight Checklist
Viper Version
1.12.2
Go Version
1.22.1
Config Source
Environment variables, Files
Format
JSON
Repl.it link
No response
Code reproducing the issue
Expected Behavior
It should be possible to bind map values through environment variables.
Actual Behavior
The environment variable is not considered.
Steps To Reproduce
Execute the code I provided.
Additional Information
When coding this, I thought it would be hard for Viper to consider this complex structure. How will the code know the map's key from the environment variable? Maybe it should have a specific separator for map keys? Like
EXAMPLE_MAP_DATA__FIRST__ENABLED
instead ofEXAMPLE_MAP_DATA_FIRST_ENABLED
? I don't know if I'm doing something wrong here.I didn't manage to create a new map key from an environment variable. I think the documentation for environment variables when using maps, slices, etc is kind of outdated and must be updated. I'm doing trial-error for several minutes trying to make this work and I don't have any idea if I'm in the right direction.
The text was updated successfully, but these errors were encountered: