1
0
mirror of https://github.com/taigrr/wtf synced 2025-01-18 04:03:14 -08:00

Remove a redundant byte conversion

Signed-off-by: Chris Cummer <chriscummer@me.com>
This commit is contained in:
Chris Cummer 2020-10-11 20:10:57 -07:00
parent b8c9f96db2
commit 21bdf18e98

View File

@ -152,7 +152,7 @@ type Monitor struct {
func (widget *Widget) getMonitors() ([]Monitor, error) { func (widget *Widget) getMonitors() ([]Monitor, error) {
// See: https://uptimerobot.com/api/#getMonitorsWrap // 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{ url.Values{
"api_key": {widget.settings.apiKey}, "api_key": {widget.settings.apiKey},
"format": {"json"}, "format": {"json"},
@ -160,18 +160,18 @@ func (widget *Widget) getMonitors() ([]Monitor, error) {
}, },
) )
if err_h != nil { if errh != nil {
return nil, err_h return nil, errh
} }
body, _ := ioutil.ReadAll(resp.Body) body, _ := ioutil.ReadAll(resp.Body)
// First pass to read the status // First pass to read the status
c := make(map[string]json.RawMessage) c := make(map[string]json.RawMessage)
err_j1 := json.Unmarshal([]byte(body), &c) errj1 := json.Unmarshal(body, &c)
if err_j1 != nil { if errj1 != nil {
return nil, err_j1 return nil, errj1
} }
if string(c["stat"]) != `"ok"` { if string(c["stat"]) != `"ok"` {
@ -180,10 +180,10 @@ func (widget *Widget) getMonitors() ([]Monitor, error) {
// Second pass to get the actual info // Second pass to get the actual info
var monitors []Monitor var monitors []Monitor
err_j2 := json.Unmarshal(c["monitors"], &monitors) errj2 := json.Unmarshal(c["monitors"], &monitors)
if err_j2 != nil { if errj2 != nil {
return nil, err_j2 return nil, errj2
} }
return monitors, nil return monitors, nil