Skip to content

Commit

Permalink
remove ioutil
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerwelin committed Apr 24, 2024
1 parent b5d6d7a commit 34b55ee
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 10 deletions.
3 changes: 1 addition & 2 deletions cmd/cassowary/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"os"
"strconv"

Expand Down Expand Up @@ -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
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/cassowary/fileops.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"bufio"
"io"
"io/ioutil"
"net/http"
"os"
"path/filepath"
Expand Down Expand Up @@ -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
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/client/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"encoding/csv"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"net/http/httptrace"
Expand Down Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/client/load_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package client
import (
"crypto/tls"
"crypto/x509"
"io/ioutil"
"net/http"
"net/http/httptest"
"os"
"testing"
)

Expand Down Expand Up @@ -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")
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/client/promgwpush_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package client

import (
"io/ioutil"
"io"
"net/http"
"net/http/httptest"
"testing"
Expand All @@ -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)
}
Expand Down

0 comments on commit 34b55ee

Please sign in to comment.