1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2026-01-07 17:47:14 +00:00

Replace uses of ioutil

ioutil package was deprecated in Go 1.16, replace all uses with their
respective replacements.

This patch was generated with a combination of `gofmt -r`, `eg`, and
manually (for `ioutil.ReadDir`).
This commit is contained in:
Alberto Bertogli
2022-11-12 20:02:52 +00:00
parent 008367d320
commit 3ebe5c5173
22 changed files with 42 additions and 61 deletions

View File

@@ -13,7 +13,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"mime"
"net"
"net/http"
@@ -266,7 +265,7 @@ func httpGet(ctx context.Context, url string) ([]byte, error) {
// Read but up to 10k; policies should be way smaller than that, and
// having a limit prevents abuse/accidents with very large replies.
return ioutil.ReadAll(&io.LimitedReader{R: resp.Body, N: 10 * 1024})
return io.ReadAll(&io.LimitedReader{R: resp.Body, N: 10 * 1024})
}
var errRejectRedirect = errors.New("redirects not allowed in MTA-STS")
@@ -385,7 +384,7 @@ func (c *PolicyCache) load(domain string) (*Policy, error) {
return nil, errExpired
}
data, err := ioutil.ReadFile(fname)
data, err := os.ReadFile(fname)
if err != nil {
cacheIOErrors.Add(1)
return nil, err
@@ -486,7 +485,7 @@ func (c *PolicyCache) refresh(ctx context.Context) {
tr := trace.New("STSCache.Refresh", c.dir)
defer tr.Finish()
entries, err := ioutil.ReadDir(c.dir)
entries, err := os.ReadDir(c.dir)
if err != nil {
tr.Errorf("failed to list directory %q: %v", c.dir, err)
return