MCPcopy
hub / github.com/spf13/viper / ReadConfig

Method ReadConfig

viper.go:1572–1583  ·  view source on GitHub ↗
(in io.Reader)

Source from the content-addressed store, hash-verified

1570func ReadConfig(in io.Reader) error { return v.ReadConfig(in) }
1571
1572func (v *Viper) ReadConfig(in io.Reader) error {
1573 config := make(map[string]any)
1574
1575 err := v.unmarshalReader(in, config)
1576 if err != nil {
1577 return err
1578 }
1579
1580 v.config = config
1581
1582 return nil
1583}
1584
1585// MergeConfig merges a new configuration with an existing config.
1586func MergeConfig(in io.Reader) error { return v.MergeConfig(in) }

Callers 15

TestDefaultFunction · 0.80
TestUnmarshalExactFunction · 0.80
TestAliasInConfigFileFunction · 0.80
TestYMLFunction · 0.80
TestJSONFunction · 0.80
TestTOMLFunction · 0.80
TestDotEnvFunction · 0.80
TestRemotePrecedenceFunction · 0.80
TestEnvFunction · 0.80
TestMultipleEnvFunction · 0.80
TestEmptyEnvFunction · 0.80
TestEmptyEnv_AllowedFunction · 0.80

Calls 1

unmarshalReaderMethod · 0.95

Tested by 15

TestDefaultFunction · 0.64
TestUnmarshalExactFunction · 0.64
TestAliasInConfigFileFunction · 0.64
TestYMLFunction · 0.64
TestJSONFunction · 0.64
TestTOMLFunction · 0.64
TestDotEnvFunction · 0.64
TestRemotePrecedenceFunction · 0.64
TestEnvFunction · 0.64
TestMultipleEnvFunction · 0.64
TestEmptyEnvFunction · 0.64
TestEmptyEnv_AllowedFunction · 0.64