[![Build Status](https://travis-ci.org/spf13/viper.svg)](https://travis-ci.org/spf13/viper) [![Join the chat at https://gitter.im/spf13/viper](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/spf13/viper?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://travis-ci.org/spf13/viper.svg)](https://travis-ci.org/spf13/viper) [![Join the chat at https://gitter.im/spf13/viper](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/spf13/viper?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![GoDoc](https://godoc.org/github.com/spf13/viper?status.svg)](https://godoc.org/github.com/spf13/viper)
## What is Viper?
Viper is a complete configuration solution for go applications including 12 factor apps. It is designed
Viper is a complete configuration solution for Go applications including 12-Factor apps. It is designed
to work within an application, and can handle all types of configuration needs
and formats. It supports:
...
...
@@ -68,7 +69,7 @@ Viper configuration keys are case insensitive.
### Establishing Defaults
A good configuration system will support default values. A default value is not
required for a key, but it's useful in the event that a key hasn’t been set via
required for a key, but it’s useful in the event that a key hasn’t been set via
config file, environment variable, remote configuration or flag.
Examples:
...
...
@@ -110,16 +111,16 @@ Gone are the days of needing to restart a server to have a config take effect,
viper powered applications can read an update to a config file while running and
not miss a beat.
Simply tell the viper instance to watchConfig.
Simply tell the viper instance to watchConfig.
Optionally you can provide a function for Viper to run each time a change occurs.
**Make sure you add all of the configPaths prior to calling `WatchConfig()`**
```go
viper.WatchConfig()
viper.OnConfigChange(func(efsnotify.Event){
fmt.Println("Config file changed:",e.Name)
})
viper.WatchConfig()
viper.OnConfigChange(func(efsnotify.Event){
fmt.Println("Config file changed:",e.Name)
})
```
### Reading Config from io.Reader
...
...
@@ -236,7 +237,7 @@ Like `BindEnv`, the value is not set when the binding method is called, but when
it is accessed. This means you can bind as early as you want, even in an
`init()` function.
The `BindPFlag()` method provides this functionality.
For individual flags, the `BindPFlag()` method provides this functionality.
Example:
...
...
@@ -245,6 +246,19 @@ serverCmd.Flags().Int("port", 1138, "Port to run Application server on")