fixes unmarshalKey doesn't work with time.Duration

This commit is contained in:
Diep Pham 2017-04-10 15:56:10 +07:00
parent 0dd8eb23d0
commit 1af7e37071

View file

@ -52,7 +52,7 @@ func init() {
type remoteConfigFactory interface {
Get(rp RemoteProvider) (io.Reader, error)
Watch(rp RemoteProvider) (io.Reader, error)
WatchChannel(rp RemoteProvider)(<-chan *RemoteResponse, chan bool)
WatchChannel(rp RemoteProvider) (<-chan *RemoteResponse, chan bool)
}
// RemoteConfig is optional, see the remote package
@ -719,7 +719,7 @@ func (v *Viper) GetSizeInBytes(key string) uint {
// UnmarshalKey takes a single key and unmarshals it into a Struct.
func UnmarshalKey(key string, rawVal interface{}) error { return v.UnmarshalKey(key, rawVal) }
func (v *Viper) UnmarshalKey(key string, rawVal interface{}) error {
return mapstructure.Decode(v.Get(key), rawVal)
return decode(v.Get(key), defaultDecoderConfig(rawVal))
}
// Unmarshal unmarshals the config into a Struct. Make sure that the tags