mirror of https://github.com/perkeep/perkeep.git
jsonconfig: sort unknown keys when returning errors
Change-Id: I5930e8b6c18581e2b9901b4d7ebc1e02af7a7be6
This commit is contained in:
parent
374c1f5360
commit
f877e849d6
|
@ -20,6 +20,7 @@ package jsonconfig
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
@ -230,6 +231,7 @@ func (jc Obj) lookForUnknownKeys() {
|
|||
if ok {
|
||||
known = ei.(map[string]bool)
|
||||
}
|
||||
var unknown []string
|
||||
for k, _ := range jc {
|
||||
if ok && known[k] {
|
||||
continue
|
||||
|
@ -239,6 +241,10 @@ func (jc Obj) lookForUnknownKeys() {
|
|||
// form of comments.
|
||||
continue
|
||||
}
|
||||
unknown = append(unknown, k)
|
||||
}
|
||||
sort.Strings(unknown)
|
||||
for _, k := range unknown {
|
||||
jc.appendError(fmt.Errorf("Unknown key %q", k))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue