Get rid of io/ioutil usage

This commit is contained in:
DarthSim
2022-10-28 21:15:13 +06:00
parent 7a0c606b68
commit e719c9d39b
5 changed files with 11 additions and 12 deletions

View File

@@ -1,7 +1,7 @@
package etag package etag
import ( import (
"io/ioutil" "io"
"os" "os"
"strings" "strings"
"testing" "testing"
@@ -36,7 +36,7 @@ type EtagTestSuite struct {
} }
func (s *EtagTestSuite) SetupSuite() { func (s *EtagTestSuite) SetupSuite() {
logrus.SetOutput(ioutil.Discard) logrus.SetOutput(io.Discard)
} }
func (s *EtagTestSuite) TeardownSuite() { func (s *EtagTestSuite) TeardownSuite() {

View File

@@ -3,7 +3,7 @@ package main
import ( import (
"context" "context"
"fmt" "fmt"
"io/ioutil" "io"
"net" "net"
"net/http" "net/http"
"os" "os"
@@ -36,7 +36,7 @@ func healthcheck() int {
} }
defer res.Body.Close() defer res.Body.Close()
msg, _ := ioutil.ReadAll(res.Body) msg, _ := io.ReadAll(res.Body)
fmt.Fprintln(os.Stderr, string(msg)) fmt.Fprintln(os.Stderr, string(msg))
if res.StatusCode != 200 { if res.StatusCode != 200 {

View File

@@ -4,7 +4,7 @@ import (
"compress/gzip" "compress/gzip"
"crypto/tls" "crypto/tls"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/http/cookiejar" "net/http/cookiejar"
"time" "time"
@@ -190,7 +190,7 @@ func requestImage(imageURL string, header http.Header, jar *cookiejar.Jar) (*htt
} }
if res.StatusCode != 200 { if res.StatusCode != 200 {
body, _ := ioutil.ReadAll(res.Body) body, _ := io.ReadAll(res.Body)
res.Body.Close() res.Body.Close()
status := 404 status := 404

View File

@@ -6,7 +6,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"github.com/imgproxy/imgproxy/v3/imagetype" "github.com/imgproxy/imgproxy/v3/imagetype"
) )
@@ -55,7 +54,7 @@ func heifDiscardN(r io.Reader, n int64) error {
return err return err
} }
_, err := io.CopyN(ioutil.Discard, r, n) _, err := io.CopyN(io.Discard, r, n)
return err return err
} }

View File

@@ -3,7 +3,7 @@ package main
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"io/ioutil" "io"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
"os" "os"
@@ -44,7 +44,7 @@ func (s *ProcessingHandlerTestSuite) SetupSuite() {
err = initialize() err = initialize()
require.Nil(s.T(), err) require.Nil(s.T(), err)
logrus.SetOutput(ioutil.Discard) logrus.SetOutput(io.Discard)
s.router = buildRouter() s.router = buildRouter()
} }
@@ -77,14 +77,14 @@ func (s *ProcessingHandlerTestSuite) readTestFile(name string) []byte {
wd, err := os.Getwd() wd, err := os.Getwd()
require.Nil(s.T(), err) require.Nil(s.T(), err)
data, err := ioutil.ReadFile(filepath.Join(wd, "testdata", name)) data, err := os.ReadFile(filepath.Join(wd, "testdata", name))
require.Nil(s.T(), err) require.Nil(s.T(), err)
return data return data
} }
func (s *ProcessingHandlerTestSuite) readBody(res *http.Response) []byte { func (s *ProcessingHandlerTestSuite) readBody(res *http.Response) []byte {
data, err := ioutil.ReadAll(res.Body) data, err := io.ReadAll(res.Body)
require.Nil(s.T(), err) require.Nil(s.T(), err)
return data return data
} }