aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/config/config.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-05-07 17:59:06 +0200
committerDmitry Vyukov <dvyukov@google.com>2018-05-07 17:59:06 +0200
commit9e0846e8a4beebff36c72f03479a7db775b5144e (patch)
tree5be248f1b661837ea2378648676e3f0f8d5746c6 /pkg/config/config.go
parent99c1f486598445575a3a624bf70dc6a31f60d365 (diff)
all: get rid of underscores in identifiers
Underscores are against Go coding style. Update #538
Diffstat (limited to 'pkg/config/config.go')
-rw-r--r--pkg/config/config.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/pkg/config/config.go b/pkg/config/config.go
index f4863916d..5502df765 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -63,10 +63,18 @@ func checkUnknownFieldsRec(data []byte, prefix string, typ reflect.Type) error {
fields := make(map[string]reflect.Type)
for i := 0; i < typ.NumField(); i++ {
field := typ.Field(i)
- if field.Tag.Get("json") == "-" {
+ tag := field.Tag.Get("json")
+ if tag == "-" {
continue
}
- fields[strings.ToLower(field.Name)] = field.Type
+ name := strings.ToLower(field.Name)
+ if tag != "" {
+ if tag != strings.ToLower(tag) {
+ return fmt.Errorf("json tag on '%v%v' should be lower-case", prefix, name)
+ }
+ name = tag
+ }
+ fields[name] = field.Type
}
f := make(map[string]interface{})
if err := json.Unmarshal(data, &f); err != nil {