This patch significantly improves `v.find` performance by using
ristretto cache.
Ristretto was chosen because it is a very performant, thread-safe
cache that does not suffer form congestion or long GC pauses.
```
% go test -bench=. .
goos: darwin
goarch: amd64
pkg: github.com/spf13/viper
BenchmarkGetBool-8 5431267 211 ns/op
BenchmarkFind/cache=false-8 289495 4060 ns/op
BenchmarkFind/cache=true-8 6980976 171 ns/op
BenchmarkGet-8 6332091 193 ns/op
BenchmarkGetBoolFromMap-8 235071828 5.09 ns/op
PASS
```
* add parsing for stringToString flags
* add logic to return flags default if not val set, add a test
* extract parsing into single func
* add a few more cases
* return nil if unable to parse instead of panicing
* return map[string]interface in order to work with cast.ToStringMap
* mostly copy pflags implementation of the conversion to a stringtostring
* Add support to save file with no extension
The support introduced for files with no file extension is only partial as trying to save the config file would fail with `<file name> requires valid extension`
This adds support to saving such files
* Only consider files without extension if the config type is explicitly specified
* Hides unused variable in test
* First check for config type then for file without extension
* Added a new `DecoderConfigOption` type allowing the user to write custom
functions that can override the default mapstructure.DecoderConfig
settings
* Added a new `DecodeHook` function which returns
a `DecoderConfigOption`. This allows the user to easily set their own
Decode hooks when Unmarshaling
* Updated Unmarshal, UnmarshalKey and defaultDecoderConfig to support variadic
trailing `DecoderConfigOption` functions to allow for customisation of
the default mapstructure.DecoderConfig
* Added a test case with example usage
Support override of symlink to config file
Include tests for WatchConfig of regular files, as well
as config file which links to a folder which is itself a
link to another folder in the same "watch dir" (the way
Kubernetes exposes config files from ConfigMaps mounted
on a volume in a Pod)
Also:
- Add synchronization with WaitGroup to ensure that the WatchConfig
is properly started before returning
- Remove the watcher when the Config file is removed.
Fixes#284
Signed-off-by: Xavier Coulon <xcoulon@redhat.com>