From 20ae272f4c5aac469eaf05713f13a5d64c5eb78a Mon Sep 17 00:00:00 2001 From: guoguangwu Date: Sun, 9 Jul 2023 16:12:33 +0800 Subject: [PATCH] chore: remove refs to deprecated io/ioutil --- internal/report/writer_test.go | 4 ++-- pkg/config/config.go | 4 ++-- pkg/popeye.go | 5 ++--- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/internal/report/writer_test.go b/internal/report/writer_test.go index ad1cc293..c2eba192 100644 --- a/internal/report/writer_test.go +++ b/internal/report/writer_test.go @@ -3,7 +3,7 @@ package report import ( "bytes" "fmt" - "io/ioutil" + "io" "strings" "testing" @@ -110,7 +110,7 @@ func TestDump(t *testing.T) { } func BenchmarkPrint(b *testing.B) { - s := NewSanitizer(ioutil.Discard, false) + s := NewSanitizer(io.Discard, false) b.ResetTimer() b.ReportAllocs() diff --git a/pkg/config/config.go b/pkg/config/config.go index f8c2b99a..c6dc1c67 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -2,7 +2,7 @@ package config import ( "fmt" - "io/ioutil" + "os" "github.com/derailed/popeye/internal/client" "gopkg.in/yaml.v2" @@ -22,7 +22,7 @@ func NewConfig(flags *Flags) (*Config, error) { cfg := Config{Popeye: NewPopeye()} if isSet(flags.Spinach) { - f, err := ioutil.ReadFile(*flags.Spinach) + f, err := os.ReadFile(*flags.Spinach) if err != nil { return nil, err } diff --git a/pkg/popeye.go b/pkg/popeye.go index ee03ae69..76031742 100644 --- a/pkg/popeye.go +++ b/pkg/popeye.go @@ -8,7 +8,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "net/http" "net/url" "os" @@ -444,10 +443,10 @@ func (p *Popeye) dumpStd(mode, header bool) error { func (p *Popeye) Do(req *http.Request) (*http.Response, error) { resp := http.Response{ // Avoid panic when the pusher tries to close the body - Body: ioutil.NopCloser(bytes.NewBufferString("Dummy response from file writer")), + Body: io.NopCloser(bytes.NewBufferString("Dummy response from file writer")), } - out, err := ioutil.ReadAll(req.Body) + out, err := io.ReadAll(req.Body) if err != nil { resp.StatusCode = http.StatusInternalServerError return &resp, err