0
Fork 0
mirror of https://github.com/willnorris/imageproxy.git synced 2024-12-16 21:56:43 -05:00

all: remove deprecated use of io/ioutil

This commit is contained in:
Will Norris 2023-01-31 20:30:38 -08:00
parent 12d8f92d33
commit 5ffd8db241
6 changed files with 9 additions and 14 deletions

View file

@ -12,7 +12,6 @@ import (
"errors"
"flag"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"os"
@ -65,7 +64,7 @@ func sign(key string, s string, urlOnly bool) ([]byte, error) {
func parseKey(s string) ([]byte, error) {
if strings.HasPrefix(s, "@") {
return ioutil.ReadFile(s[1:])
return os.ReadFile(s[1:])
}
return []byte(s), nil
}

View file

@ -4,7 +4,7 @@
package main
import (
"io/ioutil"
"io"
"net/url"
"os"
"reflect"
@ -25,7 +25,7 @@ func TestMainFunc(t *testing.T) {
main()
w.Close()
output, err := ioutil.ReadAll(r)
output, err := io.ReadAll(r)
got := string(output)
if err != nil {
t.Errorf("error reading from pipe: %v", err)
@ -94,7 +94,7 @@ func TestParseKey(t *testing.T) {
}
func TestParseKey_FilePath(t *testing.T) {
f, err := ioutil.TempFile("", "key")
f, err := os.CreateTemp("", "key")
if err != nil {
t.Errorf("error creating temp file: %v", err)
}

View file

@ -7,7 +7,6 @@ package main
import (
"flag"
"fmt"
"io/ioutil"
"log"
"net/http"
"net/url"
@ -118,7 +117,7 @@ func (skl *signatureKeyList) Set(value string) error {
if strings.HasPrefix(v, "@") {
file := strings.TrimPrefix(v, "@")
var err error
key, err = ioutil.ReadFile(file)
key, err = os.ReadFile(file)
if err != nil {
log.Fatalf("error reading signature file: %v", err)
}

View file

@ -14,7 +14,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"log"
"mime"
"net"
@ -242,7 +241,7 @@ func (p *Proxy) serveImage(w http.ResponseWriter, r *http.Request) {
if contentType == "" || contentType == "application/octet-stream" || contentType == "binary/octet-stream" {
// try to detect content type
b := bufio.NewReader(resp.Body)
resp.Body = ioutil.NopCloser(b)
resp.Body = io.NopCloser(b)
contentType = peekContentType(b)
}
if resp.ContentLength != 0 && !contentTypeMatches(p.ContentTypes, contentType) {
@ -497,7 +496,7 @@ func (t *TransformingTransport) RoundTrip(req *http.Request) (*http.Response, er
return &http.Response{StatusCode: http.StatusNotModified}, nil
}
b, err := ioutil.ReadAll(resp.Body)
b, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}

View file

@ -11,7 +11,6 @@ import (
"encoding/hex"
"errors"
"io"
"io/ioutil"
"log"
"path"
@ -35,7 +34,7 @@ func (c *cache) Get(key string) ([]byte, bool) {
}
defer r.Close()
value, err := ioutil.ReadAll(r)
value, err := io.ReadAll(r)
if err != nil {
log.Printf("error reading from gcs: %v", err)
return nil, false

View file

@ -11,7 +11,6 @@ import (
"encoding/hex"
"errors"
"io"
"io/ioutil"
"log"
"net/url"
"path"
@ -44,7 +43,7 @@ func (c *cache) Get(key string) ([]byte, bool) {
return nil, false
}
value, err := ioutil.ReadAll(resp.Body)
value, err := io.ReadAll(resp.Body)
if err != nil {
log.Printf("error reading s3 response body: %v", err)
return nil, false