From 418b4a891e92279cd8e8c90c00cd3dc8056ad5a0 Mon Sep 17 00:00:00 2001 From: "xin.li" Date: Fri, 16 Dec 2022 23:28:26 +0800 Subject: [PATCH] [truggers/cmd] clean up ioutil for new go version Signed-off-by: xin.li --- cmd/binding-eval/cmd/root.go | 3 +-- cmd/cel-eval/cmd/root.go | 5 ++--- cmd/triggerrun/cmd/root.go | 5 ++--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/cmd/binding-eval/cmd/root.go b/cmd/binding-eval/cmd/root.go index 8c38fa88e..e1e2297ea 100644 --- a/cmd/binding-eval/cmd/root.go +++ b/cmd/binding-eval/cmd/root.go @@ -21,7 +21,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "log" "net/http" "os" @@ -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) } diff --git a/cmd/cel-eval/cmd/root.go b/cmd/cel-eval/cmd/root.go index ea85ca7a4..d069253bb 100644 --- a/cmd/cel-eval/cmd/root.go +++ b/cmd/cel-eval/cmd/root.go @@ -6,7 +6,6 @@ import ( "encoding/json" "fmt" "io" - "io/ioutil" "log" "net/http" "os" @@ -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) } @@ -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) } diff --git a/cmd/triggerrun/cmd/root.go b/cmd/triggerrun/cmd/root.go index 9f8d34ce3..e06a0860d 100644 --- a/cmd/triggerrun/cmd/root.go +++ b/cmd/triggerrun/cmd/root.go @@ -24,7 +24,6 @@ import ( "errors" "fmt" "io" - "io/ioutil" "log" "net/http" "os" @@ -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 }