fix: dont use ioutils and handle error

This commit is contained in:
jon4hz
2023-03-03 23:47:54 +01:00
parent 14206de926
commit 7327698305
+5 -3
View File
@@ -4,7 +4,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"os" "os"
"os/exec" "os/exec"
@@ -55,7 +55,7 @@ func getLatestTag(repoOwner string, repoName string) (string, error) {
defer resp.Body.Close() defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body) body, err := io.ReadAll(resp.Body)
if err != nil { if err != nil {
return "", err return "", err
} }
@@ -64,7 +64,9 @@ func getLatestTag(repoOwner string, repoName string) (string, error) {
Name string `json:"name"` 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 return tags[0].Name[1:], nil
} }