diff --git a/viper.go b/viper.go index 2603c78..fce13b1 100644 --- a/viper.go +++ b/viper.go @@ -1093,9 +1093,15 @@ func (v *Viper) ReadInConfig() error { return err } - v.config = make(map[string]interface{}) + config := make(map[string]interface{}) - return v.unmarshalReader(bytes.NewReader(file), v.config) + err = v.unmarshalReader(bytes.NewReader(file), config) + if err != nil { + return err + } + + v.config = config + return nil } // MergeInConfig merges a new configuration with an existing config.