From 71af48c00f2ae38925653731b73e12dec6447a80 Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Tue, 7 Mar 2017 01:00:58 +0100 Subject: [PATCH] add quotes around field name in required field error --- genmethod.go | 2 +- internal/tests/mapconv/output.go | 8 ++++---- internal/tests/sliceconv/output.go | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/genmethod.go b/genmethod.go index ef69519..70222bc 100644 --- a/genmethod.go +++ b/genmethod.go @@ -181,7 +181,7 @@ func (m *marshalMethod) unmarshalConversions(from, to Var, format string) (s []S Body: m.convert(accessFrom, accessTo, f.typ, f.origTyp), }) } else { - err := fmt.Sprintf("missing required field %s for %s", f.encodedName(format), m.mtyp.name) + err := fmt.Sprintf("missing required field '%s' for %s", f.encodedName(format), m.mtyp.name) errors := m.scope.parent.packageName("errors") s = append(s, If{ Condition: Equals{Lhs: accessFrom, Rhs: NIL}, diff --git a/internal/tests/mapconv/output.go b/internal/tests/mapconv/output.go index c1ecea6..092a504 100644 --- a/internal/tests/mapconv/output.go +++ b/internal/tests/mapconv/output.go @@ -35,14 +35,14 @@ func (x *X) UnmarshalJSON(input []byte) error { } var x0 X if dec.Map == nil { - return errors.New("missing required field map for X") + return errors.New("missing required field 'map' for X") } x0.Map = make(map[string]int, len(dec.Map)) for k, v := range dec.Map { x0.Map[string(k)] = int(v) } if dec.Named == nil { - return errors.New("missing required field named for X") + return errors.New("missing required field 'named' for X") } x0.Named = make(namedMap, len(dec.Named)) for k, v := range dec.Named { @@ -80,14 +80,14 @@ func (x *X) UnmarshalYAML(unmarshal func(interface{}) error) error { } var x0 X if dec.Map == nil { - return errors.New("missing required field map for X") + return errors.New("missing required field 'map' for X") } x0.Map = make(map[string]int, len(dec.Map)) for k, v := range dec.Map { x0.Map[string(k)] = int(v) } if dec.Named == nil { - return errors.New("missing required field named for X") + return errors.New("missing required field 'named' for X") } x0.Named = make(namedMap, len(dec.Named)) for k, v := range dec.Named { diff --git a/internal/tests/sliceconv/output.go b/internal/tests/sliceconv/output.go index 1bbeb5d..5b8771c 100644 --- a/internal/tests/sliceconv/output.go +++ b/internal/tests/sliceconv/output.go @@ -35,14 +35,14 @@ func (x *X) UnmarshalJSON(input []byte) error { } var x0 X if dec.Slice == nil { - return errors.New("missing required field slice for X") + return errors.New("missing required field 'slice' for X") } x0.Slice = make([]int, len(dec.Slice)) for k, v := range dec.Slice { x0.Slice[k] = int(v) } if dec.Named == nil { - return errors.New("missing required field named for X") + return errors.New("missing required field 'named' for X") } x0.Named = make(namedSlice, len(dec.Named)) for k, v := range dec.Named { @@ -80,14 +80,14 @@ func (x *X) UnmarshalYAML(unmarshal func(interface{}) error) error { } var x0 X if dec.Slice == nil { - return errors.New("missing required field slice for X") + return errors.New("missing required field 'slice' for X") } x0.Slice = make([]int, len(dec.Slice)) for k, v := range dec.Slice { x0.Slice[k] = int(v) } if dec.Named == nil { - return errors.New("missing required field named for X") + return errors.New("missing required field 'named' for X") } x0.Named = make(namedSlice, len(dec.Named)) for k, v := range dec.Named {