From 3695fce1ff7e3e08289600d0474ceb1f4f3b9e3a Mon Sep 17 00:00:00 2001 From: jacobstr Date: Wed, 29 Oct 2014 22:31:20 -0600 Subject: [PATCH] Documentation for nested config access. --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 09a3d50..f3b3a8a 100644 --- a/README.md +++ b/README.md @@ -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