This commit is contained in:
parent
f9913b8a2a
commit
adf740098a
|
@ -258,6 +258,12 @@ func TestConfErrors(t *testing.T) {
|
||||||
conf string
|
conf string
|
||||||
err string
|
err string
|
||||||
}{
|
}{
|
||||||
|
{
|
||||||
|
"duplicate parameter",
|
||||||
|
"paths:\n" +
|
||||||
|
"paths:\n",
|
||||||
|
"yaml: unmarshal errors:\n line 2: key \"paths\" already set in map",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"non existent parameter 1",
|
"non existent parameter 1",
|
||||||
`invalid: param`,
|
`invalid: param`,
|
||||||
|
|
|
@ -44,8 +44,11 @@ func convertKeys(i interface{}) (interface{}, error) {
|
||||||
// Load loads the configuration from Yaml.
|
// Load loads the configuration from Yaml.
|
||||||
func Load(buf []byte, dest interface{}) error {
|
func Load(buf []byte, dest interface{}) error {
|
||||||
// load YAML into a generic map
|
// load YAML into a generic map
|
||||||
|
// from documentation:
|
||||||
|
// "UnmarshalStrict is like Unmarshal except that any fields that are found in the data
|
||||||
|
// that do not have corresponding struct members, or mapping keys that are duplicates, will result in an error."
|
||||||
var temp interface{}
|
var temp interface{}
|
||||||
err := yaml.Unmarshal(buf, &temp)
|
err := yaml.UnmarshalStrict(buf, &temp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue