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 10:45:42 +02:00
committed by GitHub
parent 4ac54040a9
commit cacc00aeb8
+3 -2
View File
@@ -4,6 +4,7 @@ import (
"bytes"
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"net/url"
@@ -224,8 +225,8 @@ func getSHA256(u string) ([]byte, error) {
return nil, fmt.Errorf("failed downloading %s: %s", u, resp.Status)
}
var sha256 []byte
if err := json.NewDecoder(resp.Body).Decode(&sha256); err != nil {
sha256, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
return sha256, nil