From fc2395025354f94fce81ddc15a3d4a6f708aea52 Mon Sep 17 00:00:00 2001 From: Tim Schindler Date: Thu, 22 Jan 2015 16:14:18 +0000 Subject: [PATCH 1/2] read raw configuration by given bytes --- viper.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/viper.go b/viper.go index 697b7ad..78108b4 100644 --- a/viper.go +++ b/viper.go @@ -559,6 +559,13 @@ func (v *Viper) ReadInConfig() error { return nil } +// ReadInRawConfig reads the given raw bytes to load configuration. +func ReadInRawConfig(raw []byte) error { return v.ReadInRawConfig(raw) } +func (v *Viper) ReadInRawConfig(raw []byte) error { + v.marshalReader(bytes.NewReader(raw), v.config) + return nil +} + func ReadRemoteConfig() error { return v.ReadRemoteConfig() } func (v *Viper) ReadRemoteConfig() error { err := v.getKeyValueConfig() From d86cab23760d691c27e5f2036dafa9405a34fcd0 Mon Sep 17 00:00:00 2001 From: Tim Schindler Date: Thu, 22 Jan 2015 16:16:15 +0000 Subject: [PATCH 2/2] comment --- viper.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/viper.go b/viper.go index 78108b4..3071df0 100644 --- a/viper.go +++ b/viper.go @@ -559,7 +559,9 @@ func (v *Viper) ReadInConfig() error { return nil } -// ReadInRawConfig reads the given raw bytes to load configuration. +// ReadInRawConfig reads the given raw bytes to load configuration. It is +// necessary to call SetConfigType(), to let viper know how to parse the given +// configuration. func ReadInRawConfig(raw []byte) error { return v.ReadInRawConfig(raw) } func (v *Viper) ReadInRawConfig(raw []byte) error { v.marshalReader(bytes.NewReader(raw), v.config)