From 10178ad8474aaec4f9c6636dea40c3a206518a70 Mon Sep 17 00:00:00 2001 From: Bill Robbins Date: Fri, 6 Feb 2015 15:00:04 -0600 Subject: [PATCH] Update for enabling cascading --- README.md | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a06bedb..60906ad 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -viper [![Build Status](https://travis-ci.org/spf13/viper.svg)](https://travis-ci.org/spf13/viper) +viper ===== Go configuration with fangs @@ -69,13 +69,29 @@ Examples: If you want to support a config file, Viper requires a minimal configuration so it knows where to look for the config file. Viper supports yaml, toml and json files. Viper can search multiple paths, but -currently a single viper only supports a single config file. +currently a single viper only supports a single config file, unless cascading is enabled. viper.SetConfigName("config") // name of config file (without extension) viper.AddConfigPath("/etc/appname/") // path to look for the config file in viper.AddConfigPath("$HOME/.appname") // call multiple times to add many search paths viper.ReadInConfig() // Find and read the config file +#### Enabling Cascading + +By default Viper stops reading configuration once it encounters the first available configuration file. +That means each configuration file must contain all configuration values you need. +By enabling cascading you can create sparse configuration files. Configuration will cascade down in +the order that files are added by AddConfigPath. For more see viper_test's cascading tests. + +Consider: + + * \etc\myapp\myapp.json + * (%GOPATH)\src\myapp\myapp.json + +You can check in a default myapp.json for development and only override certain kvps in production + + viper.EnableCascading(true) + ### Setting Overrides These could be from a command line flag, or from your own application logic.