From 9e0846e8a4beebff36c72f03479a7db775b5144e Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 7 May 2018 17:59:06 +0200 Subject: all: get rid of underscores in identifiers Underscores are against Go coding style. Update #538 --- pkg/compiler/types.go | 10 +++++----- pkg/config/config.go | 12 ++++++++++-- 2 files changed, 15 insertions(+), 7 deletions(-) (limited to 'pkg') diff --git a/pkg/compiler/types.go b/pkg/compiler/types.go index 7c874130d..825071324 100644 --- a/pkg/compiler/types.go +++ b/pkg/compiler/types.go @@ -392,15 +392,15 @@ var typeArgTextType = &typeArg{ func genTextType(t *ast.Type) prog.TextKind { switch t.Ident { case "x86_real": - return prog.Text_x86_real + return prog.TextX86Real case "x86_16": - return prog.Text_x86_16 + return prog.TextX86bit16 case "x86_32": - return prog.Text_x86_32 + return prog.TextX86bit32 case "x86_64": - return prog.Text_x86_64 + return prog.TextX86bit64 case "arm64": - return prog.Text_arm64 + return prog.TextArm64 default: panic(fmt.Sprintf("unknown text type %q", t.Ident)) } 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 { -- cgit mrf-deployment