Skip to content

Commit

Permalink
use ioutil.ReadAll so as to not create a dependency on Go 1.16
Browse files Browse the repository at this point in the history
  • Loading branch information
muir committed Oct 27, 2021
1 parent 44b6598 commit ec4bc9a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion nvelope/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"encoding/json"
"encoding/xml"
"io"
"io/ioutil"
"net/http"
"net/url"
"reflect"
Expand All @@ -28,7 +29,7 @@ var ReadBody = nject.Provide("read-body", readBody)
func readBody(r *http.Request) (Body, nject.TerminalError) {
// nolint:errcheck
defer r.Body.Close()
body, err := io.ReadAll(r.Body)
body, err := ioutil.ReadAll(r.Body)
r.Body = io.NopCloser(bytes.NewReader(body))
return Body(body), err
}
Expand Down
4 changes: 2 additions & 2 deletions nvelope/example_middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package nvelope_test
import (
"context"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/http/httptest"
"time"
Expand Down Expand Up @@ -91,7 +91,7 @@ func ExampleServiceWithMiddleware() {
fmt.Println("response error:", err)
return
}
b, err := io.ReadAll(res.Body)
b, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println("read error:", err)
return
Expand Down
4 changes: 2 additions & 2 deletions nvelope/example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package nvelope_test
import (
"errors"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"net/http/httptest"
Expand Down Expand Up @@ -90,7 +90,7 @@ func Example() {
fmt.Println("response error:", err)
return
}
b, err := io.ReadAll(res.Body)
b, err := ioutil.ReadAll(res.Body)
if err != nil {
fmt.Println("read error:", err)
return
Expand Down

0 comments on commit ec4bc9a

Please # to comment.