Use io.ReadAll instead of json.Decode (#56528) (#56529)

(cherry picked from commit df2abf09c2)

Co-authored-by: Dimitris Sotirakis <dimitrios.sotirakis@grafana.com>
This commit is contained in:
Grot (@grafanabot)
2022-10-07 04:45:42 -04:00
committed by GitHub
co-authored by Dimitris Sotirakis
parent 4ac54040a9
commit cacc00aeb8
+3 -2
View File
@@ -4,6 +4,7 @@ import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io"
"log" "log"
"net/http" "net/http"
"net/url" "net/url"
@@ -224,8 +225,8 @@ func getSHA256(u string) ([]byte, error) {
return nil, fmt.Errorf("failed downloading %s: %s", u, resp.Status) return nil, fmt.Errorf("failed downloading %s: %s", u, resp.Status)
} }
var sha256 []byte sha256, err := io.ReadAll(resp.Body)
if err := json.NewDecoder(resp.Body).Decode(&sha256); err != nil { if err != nil {
return nil, err return nil, err
} }
return sha256, nil return sha256, nil