From bf49a23df85154546a83714ad9eb966eb5e2d550 Mon Sep 17 00:00:00 2001 From: WithoutPants <53250216+WithoutPants@users.noreply.github.com> Date: Wed, 19 Feb 2020 07:56:24 +1100 Subject: [PATCH] Fix panic when version check times out (#374) --- pkg/api/check_version.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkg/api/check_version.go b/pkg/api/check_version.go index c0eb7370e..4e4ed3fe7 100644 --- a/pkg/api/check_version.go +++ b/pkg/api/check_version.go @@ -124,14 +124,14 @@ func GetLatestVersion(shortHash bool) (latestVersion string, latestRelease strin release := githubReleasesResponse{} - if response.StatusCode != http.StatusOK { - return "", "", fmt.Errorf("Github API request failed: %s", response.Status) - } - if err != nil { return "", "", fmt.Errorf("Github API request failed: %s", err) } + if response.StatusCode != http.StatusOK { + return "", "", fmt.Errorf("Github API request failed: %s", response.Status) + } + defer response.Body.Close() data, err := ioutil.ReadAll(response.Body)