From d3fa3ffd40e8ecdaf2216127eabb4b7feccf8878 Mon Sep 17 00:00:00 2001 From: Elena Morozova Date: Tue, 3 Oct 2017 23:10:42 -0700 Subject: [PATCH] Close body after error check Otherwise it panics for nil body --- pkg/notifications/slack/slack.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/notifications/slack/slack.go b/pkg/notifications/slack/slack.go index 0595daf..e01ffc1 100644 --- a/pkg/notifications/slack/slack.go +++ b/pkg/notifications/slack/slack.go @@ -29,10 +29,10 @@ func NotifyReboot(hookURL, username, nodeID string) error { } resp, err := httpClient.Post(hookURL, "application/json", &buf) - defer resp.Body.Close() if err != nil { return err } + defer resp.Body.Close() if resp.StatusCode < 200 || resp.StatusCode >= 300 { return fmt.Errorf(resp.Status)