From 21bdf18e9842a4f417e8f682f9dd1ba0008905fe Mon Sep 17 00:00:00 2001 From: Chris Cummer Date: Sun, 11 Oct 2020 20:10:57 -0700 Subject: [PATCH] Remove a redundant byte conversion Signed-off-by: Chris Cummer --- modules/uptimerobot/widget.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/uptimerobot/widget.go b/modules/uptimerobot/widget.go index bcb69d24..a905e354 100644 --- a/modules/uptimerobot/widget.go +++ b/modules/uptimerobot/widget.go @@ -152,7 +152,7 @@ type Monitor struct { func (widget *Widget) getMonitors() ([]Monitor, error) { // See: https://uptimerobot.com/api/#getMonitorsWrap - resp, err_h := http.PostForm("https://api.uptimerobot.com/v2/getMonitors", + resp, errh := http.PostForm("https://api.uptimerobot.com/v2/getMonitors", url.Values{ "api_key": {widget.settings.apiKey}, "format": {"json"}, @@ -160,18 +160,18 @@ func (widget *Widget) getMonitors() ([]Monitor, error) { }, ) - if err_h != nil { - return nil, err_h + if errh != nil { + return nil, errh } body, _ := ioutil.ReadAll(resp.Body) // First pass to read the status c := make(map[string]json.RawMessage) - err_j1 := json.Unmarshal([]byte(body), &c) + errj1 := json.Unmarshal(body, &c) - if err_j1 != nil { - return nil, err_j1 + if errj1 != nil { + return nil, errj1 } if string(c["stat"]) != `"ok"` { @@ -180,10 +180,10 @@ func (widget *Widget) getMonitors() ([]Monitor, error) { // Second pass to get the actual info var monitors []Monitor - err_j2 := json.Unmarshal(c["monitors"], &monitors) + errj2 := json.Unmarshal(c["monitors"], &monitors) - if err_j2 != nil { - return nil, err_j2 + if errj2 != nil { + return nil, errj2 } return monitors, nil