Skip to content

Commit

Permalink
[truggers/cmd] clean up ioutil for new go version
Browse files Browse the repository at this point in the history
Signed-off-by: xin.li <[email protected]>
  • Loading branch information
my-git9 committed Dec 16, 2022
1 parent a1995aa commit 116c9ab
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
3 changes: 1 addition & 2 deletions cmd/binding-eval/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -138,7 +137,7 @@ func readHTTP(path string) (*http.Request, []byte, error) {
return nil, nil, fmt.Errorf("error reading request: %w", err)
}
defer req.Body.Close()
body, err := ioutil.ReadAll(req.Body)
body, err := io.ReadAll(req.Body)
if err != nil {
return nil, nil, fmt.Errorf("error reading HTTP body: %w", err)
}
Expand Down
5 changes: 2 additions & 3 deletions cmd/cel-eval/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -118,7 +117,7 @@ func readExpression(path string) (string, error) {
}
defer f.Close()

data, err := ioutil.ReadAll(f)
data, err := io.ReadAll(f)
if err != nil {
return "", fmt.Errorf("error reading from file: %w", err)
}
Expand All @@ -138,7 +137,7 @@ func readHTTP(path string) (*http.Request, []byte, error) {
return nil, nil, fmt.Errorf("error reading request: %w", err)
}
defer req.Body.Close()
body, err := ioutil.ReadAll(req.Body)
body, err := io.ReadAll(req.Body)
if err != nil {
return nil, nil, fmt.Errorf("error reading HTTP body: %w", err)
}
Expand Down
5 changes: 2 additions & 3 deletions cmd/triggerrun/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"os"
Expand Down Expand Up @@ -179,13 +178,13 @@ func readHTTP(path string) (*http.Request, []byte, error) {
return nil, nil, fmt.Errorf("error reading HTTP file: %w", err)
}

body, err := ioutil.ReadAll(request.Body)
body, err := io.ReadAll(request.Body)
defer request.Body.Close()
if err != nil {
return nil, nil, fmt.Errorf("error reading HTTP body: %w", err)
}

request.Body = ioutil.NopCloser(bytes.NewReader(body))
request.Body = io.NopCloser(bytes.NewReader(body))

return request, body, err
}
Expand Down

0 comments on commit 116c9ab

Please sign in to comment.