From 6aece86ac15427faae5efe6ed651d1a8e5b7cf77 Mon Sep 17 00:00:00 2001 From: Kellen Fox Date: Mon, 8 May 2017 11:25:25 -0700 Subject: [PATCH] Fixes #746 Found that we are only defining MarshalJSON for the Regexp type for references not for the direct object Also took the time to simplify the json.Unmarshal usage in cli/config.go --- cli/config.go | 6 ++---- config/config.go | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/cli/config.go b/cli/config.go index 045cc17c..44af95dd 100644 --- a/cli/config.go +++ b/cli/config.go @@ -74,12 +74,10 @@ func fetchConfig() (Config, error) { } defer res.Body.Close() - decoder := json.NewDecoder(res.Body) - err = decoder.Decode(&configResponse) + err = json.NewDecoder(res.Body).Decode(&configResponse) if err != nil { - panic(err) - return Config{}, err + return configResponse.Data, err } if configResponse.Status != "success" { diff --git a/config/config.go b/config/config.go index 52e4ea22..84b2d736 100644 --- a/config/config.go +++ b/config/config.go @@ -503,7 +503,7 @@ func (re *Regexp) UnmarshalJSON(data []byte) error { } // MarshalJSON implements the json.Marshaler interface. -func (re *Regexp) MarshalJSON() ([]byte, error) { +func (re Regexp) MarshalJSON() ([]byte, error) { if re.Regexp != nil { return json.Marshal(re.String()) }