Documentation for nested config access.

This commit is contained in:
jacobstr 2014-10-29 22:31:20 -06:00
parent 0b15bed35b
commit 3695fce1ff

View file

@ -70,6 +70,16 @@ Viper configuration keys are case insensitive.
fmt.Println("verbose enabled")
}
### Deep Configuration Data
// Materialized paths allow for deep traversal of nested config data.
logger_config := viper.GetStringMap("logger.stdout")
// Or, go even deeper.
logger_base_path := viper.GetString("logger.stdout.base_path")
// Periods are not valid environment variable names, replace
// materialized path periods with double underscores.
LOGGER__STDOUT__BASE_PATH=/var/log/myapp go run server.go
## Q & A