Skip to content

Commit e719c9d

Browse files
committed
Get rid of io/ioutil usage
1 parent 7a0c606 commit e719c9d

File tree

5 files changed

+11
-12
lines changed

5 files changed

+11
-12
lines changed

etag/etag_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package etag
22

33
import (
4-
"io/ioutil"
4+
"io"
55
"os"
66
"strings"
77
"testing"
@@ -36,7 +36,7 @@ type EtagTestSuite struct {
3636
}
3737

3838
func (s *EtagTestSuite) SetupSuite() {
39-
logrus.SetOutput(ioutil.Discard)
39+
logrus.SetOutput(io.Discard)
4040
}
4141

4242
func (s *EtagTestSuite) TeardownSuite() {

healthcheck.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package main
33
import (
44
"context"
55
"fmt"
6-
"io/ioutil"
6+
"io"
77
"net"
88
"net/http"
99
"os"
@@ -36,7 +36,7 @@ func healthcheck() int {
3636
}
3737
defer res.Body.Close()
3838

39-
msg, _ := ioutil.ReadAll(res.Body)
39+
msg, _ := io.ReadAll(res.Body)
4040
fmt.Fprintln(os.Stderr, string(msg))
4141

4242
if res.StatusCode != 200 {

imagedata/download.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"compress/gzip"
55
"crypto/tls"
66
"fmt"
7-
"io/ioutil"
7+
"io"
88
"net/http"
99
"net/http/cookiejar"
1010
"time"
@@ -190,7 +190,7 @@ func requestImage(imageURL string, header http.Header, jar *cookiejar.Jar) (*htt
190190
}
191191

192192
if res.StatusCode != 200 {
193-
body, _ := ioutil.ReadAll(res.Body)
193+
body, _ := io.ReadAll(res.Body)
194194
res.Body.Close()
195195

196196
status := 404

imagemeta/heif.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"errors"
77
"fmt"
88
"io"
9-
"io/ioutil"
109

1110
"github.com/imgproxy/imgproxy/v3/imagetype"
1211
)
@@ -55,7 +54,7 @@ func heifDiscardN(r io.Reader, n int64) error {
5554
return err
5655
}
5756

58-
_, err := io.CopyN(ioutil.Discard, r, n)
57+
_, err := io.CopyN(io.Discard, r, n)
5958
return err
6059
}
6160

processing_handler_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package main
33
import (
44
"bytes"
55
"fmt"
6-
"io/ioutil"
6+
"io"
77
"net/http"
88
"net/http/httptest"
99
"os"
@@ -44,7 +44,7 @@ func (s *ProcessingHandlerTestSuite) SetupSuite() {
4444
err = initialize()
4545
require.Nil(s.T(), err)
4646

47-
logrus.SetOutput(ioutil.Discard)
47+
logrus.SetOutput(io.Discard)
4848

4949
s.router = buildRouter()
5050
}
@@ -77,14 +77,14 @@ func (s *ProcessingHandlerTestSuite) readTestFile(name string) []byte {
7777
wd, err := os.Getwd()
7878
require.Nil(s.T(), err)
7979

80-
data, err := ioutil.ReadFile(filepath.Join(wd, "testdata", name))
80+
data, err := os.ReadFile(filepath.Join(wd, "testdata", name))
8181
require.Nil(s.T(), err)
8282

8383
return data
8484
}
8585

8686
func (s *ProcessingHandlerTestSuite) readBody(res *http.Response) []byte {
87-
data, err := ioutil.ReadAll(res.Body)
87+
data, err := io.ReadAll(res.Body)
8888
require.Nil(s.T(), err)
8989
return data
9090
}

0 commit comments

Comments
 (0)