From 639d4dad0a3c8071932666e67e3dc86b02ee9e38 Mon Sep 17 00:00:00 2001 From: Jed Borovik Date: Sat, 12 Sep 2015 18:48:38 -0400 Subject: [PATCH] Minor tweaks to null.Time UnmarshalJSON --- time.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/time.go b/time.go index d69f28c..474a2cf 100644 --- a/time.go +++ b/time.go @@ -86,14 +86,11 @@ func (t *Time) UnmarshalJSON(data []byte) error { ti, tiOK := x["Time"].(string) valid, validOK := x["Valid"].(bool) if !tiOK || !validOK { - err = fmt.Errorf("json: unmarshalling map[string]interface{} into Go value of type null.Time requires key \"Time\" to be of type string and key \"Valid\" to be of type bool; found %T and %T, respectively", x["Time"], x["Valid"]) - break + return fmt.Errorf("json: unmarshalling JSON object into Go value of type null.Time requires key \"Time\" to be of type string and key \"Valid\" to be of type bool; found %T and %T, respectively", x["Time"], x["Valid"]) } err = t.Time.UnmarshalJSON([]byte(`"` + ti + `"`)) t.Valid = valid - if err == nil && t.Valid == false { - return nil // Return here to prevent `Valid` from being set to true based on nil error below. - } + return err case nil: t.Valid = false return nil