Handle ioutil deprecations (#53526)

* replace ioutil.ReadFile -> os.ReadFile

* replace ioutil.ReadAll -> io.ReadAll

* replace ioutil.TempFile -> os.CreateTemp

* replace ioutil.NopCloser -> io.NopCloser

* replace ioutil.WriteFile -> os.WriteFile

* replace ioutil.TempDir -> os.MkdirTemp

* replace ioutil.Discard -> io.Discard
This commit is contained in:
Jo
2022-08-10 13:37:51 +00:00
committed by GitHub
parent 4926767737
commit 062d255124
140 changed files with 462 additions and 492 deletions

View File

@@ -3,7 +3,7 @@ package updatechecker
import (
"context"
"encoding/json"
"io/ioutil"
"io"
"net/http"
"strings"
"sync"
@@ -68,7 +68,7 @@ func (s *GrafanaService) checkForUpdates() {
s.log.Warn("Failed to close response body", "err", err)
}
}()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
s.log.Debug("Update check failed, reading response from github.com", "error", err)
return

View File

@@ -3,7 +3,7 @@ package updatechecker
import (
"context"
"encoding/json"
"io/ioutil"
"io"
"net/http"
"strings"
"sync"
@@ -99,7 +99,7 @@ func (s *PluginsService) checkForUpdates(ctx context.Context) {
}
}()
body, err := ioutil.ReadAll(resp.Body)
body, err := io.ReadAll(resp.Body)
if err != nil {
s.log.Debug("Update check failed, reading response from grafana.com", "error", err.Error())
return

View File

@@ -2,7 +2,7 @@ package updatechecker
import (
"context"
"io/ioutil"
"io"
"net/http"
"strings"
"testing"
@@ -190,7 +190,7 @@ func (c *fakeHTTPClient) Get(url string) (*http.Response, error) {
c.requestURL = url
resp := &http.Response{
Body: ioutil.NopCloser(strings.NewReader(c.fakeResp)),
Body: io.NopCloser(strings.NewReader(c.fakeResp)),
}
return resp, nil