From 7327698305cecd5df2b37e8c007cd81e97a8d938 Mon Sep 17 00:00:00 2001 From: jon4hz Date: Fri, 3 Mar 2023 22:36:51 +0100 Subject: [PATCH] fix: dont use ioutils and handle error --- cli/packages/util/check-for-update.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cli/packages/util/check-for-update.go b/cli/packages/util/check-for-update.go index 220b098e9..28a1890c8 100644 --- a/cli/packages/util/check-for-update.go +++ b/cli/packages/util/check-for-update.go @@ -4,7 +4,7 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" + "io" "net/http" "os" "os/exec" @@ -55,7 +55,7 @@ func getLatestTag(repoOwner string, repoName string) (string, error) { defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) + body, err := io.ReadAll(resp.Body) if err != nil { return "", err } @@ -64,7 +64,9 @@ func getLatestTag(repoOwner string, repoName string) (string, error) { Name string `json:"name"` } - json.Unmarshal(body, &tags) + if err := json.Unmarshal(body, &tags); err != nil { + return "", fmt.Errorf("failed to unmarshal github response: %w", err) + } return tags[0].Name[1:], nil }