mirror of
https://github.com/spf13/viper
synced 2025-05-06 12:17:18 +00:00
Documentation for nested config access.
This commit is contained in:
parent
0b15bed35b
commit
3695fce1ff
1 changed files with 10 additions and 0 deletions
10
README.md
10
README.md
|
@ -70,6 +70,16 @@ Viper configuration keys are case insensitive.
|
||||||
fmt.Println("verbose enabled")
|
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
|
## Q & A
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue