Skip to content

Commit

Permalink
replaced usage of obsolete ioutil functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Hempel committed Oct 28, 2024
1 parent d341bfd commit 536312f
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 13 deletions.
4 changes: 2 additions & 2 deletions api_testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"os"
Expand Down Expand Up @@ -442,7 +442,7 @@ func (ats *Suite) loadManifest() ([]byte, error) {
}
defer manifestFile.Close()

manifestTmpl, err := ioutil.ReadAll(manifestFile)
manifestTmpl, err := io.ReadAll(manifestFile)
if err != nil {
return res, fmt.Errorf("error loading manifest (%s): %s", ats.manifestPath, err)
}
Expand Down
3 changes: 1 addition & 2 deletions http_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"encoding/json"
"io"
"io/ioutil"
"net/http"
"net/url"
"path/filepath"
Expand Down Expand Up @@ -155,7 +154,7 @@ func bounceJSON(w http.ResponseWriter, r *http.Request) {
bodyJSON, errorBody any
)

bodyBytes, err = ioutil.ReadAll(r.Body)
bodyBytes, err = io.ReadAll(r.Body)

if utf8.Valid(bodyBytes) {
if len(bodyBytes) > 0 {
Expand Down
4 changes: 2 additions & 2 deletions internal/httpproxy/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package httpproxy
import (
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"strconv"
Expand Down Expand Up @@ -63,7 +63,7 @@ func (st *store) write(w http.ResponseWriter, r *http.Request) {
offset := len(st.Data)

if r.Body != nil {
reqData.Body, err = ioutil.ReadAll(r.Body)
reqData.Body, err = io.ReadAll(r.Body)
if err != nil {
handlerutil.RespondWithErr(w, http.StatusInternalServerError, errors.Errorf("Could not read request body: %s", err))
return
Expand Down
3 changes: 1 addition & 2 deletions pkg/lib/api/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/http/httputil"
"net/url"
Expand Down Expand Up @@ -293,7 +292,7 @@ func (request Request) ToString(curl bool) (res string) {
// return r.Replace(curl.String())
}

_, _ = io.Copy(ioutil.Discard, httpRequest.Body)
_, _ = io.Copy(io.Discard, httpRequest.Body)
_ = httpRequest.Body.Close()

curl, _ := http2curl.GetCurlCommand(httpRequest)
Expand Down
3 changes: 1 addition & 2 deletions pkg/lib/api/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/http"
"strings"
"time"
Expand Down Expand Up @@ -102,7 +101,7 @@ func NewResponse(statusCode int,
}
if body != nil {
start := time.Now()
res.Body, err = ioutil.ReadAll(body)
res.Body, err = io.ReadAll(body)
if err != nil {
return res, err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/lib/report/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package report

import (
"fmt"
"io/ioutil"
"os"
"sync"
"time"

Expand Down Expand Up @@ -196,7 +196,7 @@ func (r *Report) WriteToFile(reportFile, reportFormat string) error {
parsingFunction = ParseJSONResult
}

err := ioutil.WriteFile(reportFile, r.GetTestResult(parsingFunction), 0644)
err := os.WriteFile(reportFile, r.GetTestResult(parsingFunction), 0644)
if err != nil {
logrus.Errorf("Could not save report into file: %s", err)
return err
Expand Down
2 changes: 1 addition & 1 deletion pkg/lib/template/template_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (loader *Loader) Render(
// if err != nil {
// return nil, err
// }
// fileBytes, err := ioutil.ReadAll(file)
// fileBytes, err := io.ReadAll(file)
// if err != nil {
// return nil, err
// }
Expand Down

0 comments on commit 536312f

Please sign in to comment.