Skip to content

Commit e733481

Browse files
authored
Merge pull request #1750 from zaunist/fix/deprecation
fix: Deprecation of package ioutil in Go 1.16
2 parents d660316 + 5870c4a commit e733481

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

.golangci.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ linters:
1313
- goimports
1414
- revive
1515
- govet
16+
- gomodguard
1617
- misspell
1718
- exportloopref
1819
disable:
@@ -36,7 +37,16 @@ linters-settings:
3637
check-shadowing: true
3738
misspell:
3839
locale: US
39-
ignore-words:
40+
ignore-words: []
41+
gomodguard:
42+
blocked:
43+
# List of blocked modules.
44+
modules:
45+
- io/ioutil:
46+
recommendations:
47+
- io
48+
- os
49+
reason: "Deprecation of package ioutil in Go 1.16."
4050

4151
issues:
4252
exclude-rules:

conformance/utils/roundtripper/roundtripper.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import (
2323
"encoding/json"
2424
"fmt"
2525
"io"
26-
iou "io/ioutil"
2726
"net/http"
2827
"net/http/httputil"
2928
"net/url"
@@ -182,7 +181,10 @@ func (d *DefaultRoundTripper) CaptureRoundTrip(request Request) (*CapturedReques
182181
fmt.Printf("Received Response:\n%s\n\n", formatDump(dump, "< "))
183182
}
184183

185-
body, _ := iou.ReadAll(resp.Body)
184+
body, err := io.ReadAll(resp.Body)
185+
if err != nil {
186+
return nil, nil, err
187+
}
186188

187189
// we cannot assume the response is JSON
188190
if resp.Header.Get("Content-type") == "application/json" {

0 commit comments

Comments
 (0)