From 34b55ee2b3a6b677c08ff1280f4a377b970a2852 Mon Sep 17 00:00:00 2001 From: rogerwelin Date: Wed, 24 Apr 2024 23:40:57 +0200 Subject: [PATCH] remove ioutil --- cmd/cassowary/cli.go | 3 +-- cmd/cassowary/fileops.go | 3 +-- pkg/client/load.go | 3 +-- pkg/client/load_test.go | 4 ++-- pkg/client/promgwpush_test.go | 4 ++-- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/cmd/cassowary/cli.go b/cmd/cassowary/cli.go index 9bf1b44..daa0eeb 100644 --- a/cmd/cassowary/cli.go +++ b/cmd/cassowary/cli.go @@ -6,7 +6,6 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" "os" "strconv" @@ -180,7 +179,7 @@ func validateCLI(c *cli.Context) error { } if c.String("ca") != "" { - pemCerts, err := ioutil.ReadFile(c.String("ca")) + pemCerts, err := os.ReadFile(c.String("ca")) if err != nil { return err } diff --git a/cmd/cassowary/fileops.go b/cmd/cassowary/fileops.go index bad6306..5cf666c 100644 --- a/cmd/cassowary/fileops.go +++ b/cmd/cassowary/fileops.go @@ -3,7 +3,6 @@ package main import ( "bufio" "io" - "io/ioutil" "net/http" "os" "path/filepath" @@ -38,7 +37,7 @@ func downloadPath(url string) (string, error) { } func readFile(file string) ([]byte, error) { - fileContent, err := ioutil.ReadFile(file) + fileContent, err := os.ReadFile(file) if err != nil { return []byte{}, err } diff --git a/pkg/client/load.go b/pkg/client/load.go index 1a2f23f..84a14d5 100644 --- a/pkg/client/load.go +++ b/pkg/client/load.go @@ -7,7 +7,6 @@ import ( "encoding/csv" "fmt" "io" - "io/ioutil" "log" "net/http" "net/http/httptrace" @@ -102,7 +101,7 @@ func (c *Cassowary) runLoadTest(outPutChan chan<- durationMetrics, workerChan ch log.Fatalf("%v", err) } if resp != nil { - _, err = io.Copy(ioutil.Discard, resp.Body) + _, err = io.Copy(io.Discard, resp.Body) if err != nil { fmt.Println("Failed to read HTTP response body", err) } diff --git a/pkg/client/load_test.go b/pkg/client/load_test.go index 94bea3d..0006fe1 100644 --- a/pkg/client/load_test.go +++ b/pkg/client/load_test.go @@ -3,9 +3,9 @@ package client import ( "crypto/tls" "crypto/x509" - "io/ioutil" "net/http" "net/http/httptest" + "os" "testing" ) @@ -83,7 +83,7 @@ func TestCoordinateTLSConfig(t *testing.T) { w.Write([]byte("ok")) })) - pemCerts, err := ioutil.ReadFile("testdata/ca.pem") + pemCerts, err := os.ReadFile("testdata/ca.pem") if err != nil { t.Fatal("Invalid ca.pem path") } diff --git a/pkg/client/promgwpush_test.go b/pkg/client/promgwpush_test.go index 5d03296..0b3c166 100644 --- a/pkg/client/promgwpush_test.go +++ b/pkg/client/promgwpush_test.go @@ -1,7 +1,7 @@ package client import ( - "io/ioutil" + "io" "net/http" "net/http/httptest" "testing" @@ -18,7 +18,7 @@ func TestPromGwPush(t *testing.T) { http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { lastMethod = r.Method var err error - _, err = ioutil.ReadAll(r.Body) + _, err = io.ReadAll(r.Body) if err != nil { t.Fatal(err) }