forked from mirror/viper
replace bytes.Buffer with io.Reader
This commit is contained in:
parent
2a7f7f40fc
commit
f3482afcd0
13
viper.go
13
viper.go
|
@ -716,13 +716,20 @@ func (v *Viper) ReadInConfig() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadBufConfig(buf *bytes.Buffer) error { return v.ReadBufConfig(buf) }
|
func ReadConfig(in io.Reader) error { return v.ReadConfig(in) }
|
||||||
func (v *Viper) ReadBufConfig(buf *bytes.Buffer) error {
|
func (v *Viper) ReadConfig(in io.Reader) error {
|
||||||
v.config = make(map[string]interface{})
|
v.config = make(map[string]interface{})
|
||||||
v.marshalReader(buf, v.config)
|
v.marshalReader(in, v.config)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// func ReadBufConfig(buf *bytes.Buffer) error { return v.ReadBufConfig(buf) }
|
||||||
|
// func (v *Viper) ReadBufConfig(buf *bytes.Buffer) error {
|
||||||
|
// v.config = make(map[string]interface{})
|
||||||
|
// v.marshalReader(buf, v.config)
|
||||||
|
// return nil
|
||||||
|
// }
|
||||||
|
|
||||||
// Attempts to get configuration from a remote source
|
// Attempts to get configuration from a remote source
|
||||||
// and read it in the remote configuration registry.
|
// and read it in the remote configuration registry.
|
||||||
func ReadRemoteConfig() error { return v.ReadRemoteConfig() }
|
func ReadRemoteConfig() error { return v.ReadRemoteConfig() }
|
||||||
|
|
|
@ -541,7 +541,7 @@ func TestFindsNestedKeys(t *testing.T) {
|
||||||
func TestReadBufConfig(t *testing.T) {
|
func TestReadBufConfig(t *testing.T) {
|
||||||
v := New()
|
v := New()
|
||||||
v.SetConfigType("yaml")
|
v.SetConfigType("yaml")
|
||||||
v.ReadBufConfig(bytes.NewBuffer(yamlExample))
|
v.ReadConfig(bytes.NewBuffer(yamlExample))
|
||||||
t.Log(v.AllKeys())
|
t.Log(v.AllKeys())
|
||||||
|
|
||||||
assert.True(t, v.InConfig("name"))
|
assert.True(t, v.InConfig("name"))
|
||||||
|
|
Loading…
Reference in New Issue