jsonconfig: sort unknown keys when returning errors

Change-Id: I5930e8b6c18581e2b9901b4d7ebc1e02af7a7be6
This commit is contained in:
Brad Fitzpatrick 2012-03-19 13:07:17 -07:00
parent 374c1f5360
commit f877e849d6
1 changed files with 6 additions and 0 deletions

View File

@ -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))
}
}