diff options
author | Russ Cox <rsc@golang.org> | 2020-10-16 00:49:02 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2020-10-20 18:41:18 +0000 |
commit | 1b09d430678d4a6f73b2443463d11f75851aba8a (patch) | |
tree | fec040abfc6e1d897f8dcdbb856e77d5bccbb2ca /src/archive | |
parent | cb0a0f52e67f128c6ad69027c9a8c7a5caf58446 (diff) | |
download | go-1b09d430678d4a6f73b2443463d11f75851aba8a.tar.gz go-1b09d430678d4a6f73b2443463d11f75851aba8a.zip |
all: update references to symbols moved from io/ioutil to io
The old ioutil references are still valid, but update our code
to reflect best practices and get used to the new locations.
Code compiled with the bootstrap toolchain
(cmd/asm, cmd/dist, cmd/compile, debug/elf)
must remain Go 1.4-compatible and is excluded.
Also excluded vendored code.
For #41190.
Change-Id: I6d86f2bf7bc37a9d904b6cee3fe0c7af6d94d5b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/263142
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Diffstat (limited to 'src/archive')
-rw-r--r-- | src/archive/tar/reader.go | 7 | ||||
-rw-r--r-- | src/archive/tar/reader_test.go | 2 | ||||
-rw-r--r-- | src/archive/tar/tar_test.go | 8 | ||||
-rw-r--r-- | src/archive/zip/reader_test.go | 6 | ||||
-rw-r--r-- | src/archive/zip/register.go | 3 | ||||
-rw-r--r-- | src/archive/zip/writer_test.go | 4 | ||||
-rw-r--r-- | src/archive/zip/zip_test.go | 3 |
7 files changed, 15 insertions, 18 deletions
diff --git a/src/archive/tar/reader.go b/src/archive/tar/reader.go index 4f9135b791..1b1d5b4689 100644 --- a/src/archive/tar/reader.go +++ b/src/archive/tar/reader.go @@ -7,7 +7,6 @@ package tar import ( "bytes" "io" - "io/ioutil" "strconv" "strings" "time" @@ -104,7 +103,7 @@ func (tr *Reader) next() (*Header, error) { continue // This is a meta header affecting the next header case TypeGNULongName, TypeGNULongLink: format.mayOnlyBe(FormatGNU) - realname, err := ioutil.ReadAll(tr) + realname, err := io.ReadAll(tr) if err != nil { return nil, err } @@ -294,7 +293,7 @@ func mergePAX(hdr *Header, paxHdrs map[string]string) (err error) { // parsePAX parses PAX headers. // If an extended header (type 'x') is invalid, ErrHeader is returned func parsePAX(r io.Reader) (map[string]string, error) { - buf, err := ioutil.ReadAll(r) + buf, err := io.ReadAll(r) if err != nil { return nil, err } @@ -850,7 +849,7 @@ func discard(r io.Reader, n int64) error { } } - copySkipped, err := io.CopyN(ioutil.Discard, r, n-seekSkipped) + copySkipped, err := io.CopyN(io.Discard, r, n-seekSkipped) if err == io.EOF && seekSkipped+copySkipped < n { err = io.ErrUnexpectedEOF } diff --git a/src/archive/tar/reader_test.go b/src/archive/tar/reader_test.go index f153b668de..411d1e0b99 100644 --- a/src/archive/tar/reader_test.go +++ b/src/archive/tar/reader_test.go @@ -865,7 +865,7 @@ func TestReadTruncation(t *testing.T) { } cnt++ if s2 == "manual" { - if _, err = tr.writeTo(ioutil.Discard); err != nil { + if _, err = tr.writeTo(io.Discard); err != nil { break } } diff --git a/src/archive/tar/tar_test.go b/src/archive/tar/tar_test.go index f605dae904..d4a3d42312 100644 --- a/src/archive/tar/tar_test.go +++ b/src/archive/tar/tar_test.go @@ -328,7 +328,7 @@ func TestRoundTrip(t *testing.T) { if !reflect.DeepEqual(rHdr, hdr) { t.Errorf("Header mismatch.\n got %+v\nwant %+v", rHdr, hdr) } - rData, err := ioutil.ReadAll(tr) + rData, err := io.ReadAll(tr) if err != nil { t.Fatalf("Read: %v", err) } @@ -805,9 +805,9 @@ func Benchmark(b *testing.B) { b.Run(v.label, func(b *testing.B) { b.ReportAllocs() for i := 0; i < b.N; i++ { - // Writing to ioutil.Discard because we want to + // Writing to io.Discard because we want to // test purely the writer code and not bring in disk performance into this. - tw := NewWriter(ioutil.Discard) + tw := NewWriter(io.Discard) for _, file := range v.files { if err := tw.WriteHeader(file.hdr); err != nil { b.Errorf("unexpected WriteHeader error: %v", err) @@ -845,7 +845,7 @@ func Benchmark(b *testing.B) { if _, err := tr.Next(); err != nil { b.Errorf("unexpected Next error: %v", err) } - if _, err := io.Copy(ioutil.Discard, tr); err != nil { + if _, err := io.Copy(io.Discard, tr); err != nil { b.Errorf("unexpected Copy error : %v", err) } } diff --git a/src/archive/zip/reader_test.go b/src/archive/zip/reader_test.go index 38ff7badd0..b7a7d7a757 100644 --- a/src/archive/zip/reader_test.go +++ b/src/archive/zip/reader_test.go @@ -930,7 +930,7 @@ func returnBigZipBytes() (r io.ReaderAt, size int64) { if err != nil { panic(err) } - b, err = ioutil.ReadAll(f) + b, err = io.ReadAll(f) if err != nil { panic(err) } @@ -987,7 +987,7 @@ func TestIssue10957(t *testing.T) { continue } if f.UncompressedSize64 < 1e6 { - n, err := io.Copy(ioutil.Discard, r) + n, err := io.Copy(io.Discard, r) if i == 3 && err != io.ErrUnexpectedEOF { t.Errorf("File[3] error = %v; want io.ErrUnexpectedEOF", err) } @@ -1029,7 +1029,7 @@ func TestIssue11146(t *testing.T) { if err != nil { t.Fatal(err) } - _, err = ioutil.ReadAll(r) + _, err = io.ReadAll(r) if err != io.ErrUnexpectedEOF { t.Errorf("File[0] error = %v; want io.ErrUnexpectedEOF", err) } diff --git a/src/archive/zip/register.go b/src/archive/zip/register.go index 51e9c3e4d4..4389246286 100644 --- a/src/archive/zip/register.go +++ b/src/archive/zip/register.go @@ -8,7 +8,6 @@ import ( "compress/flate" "errors" "io" - "io/ioutil" "sync" ) @@ -111,7 +110,7 @@ func init() { compressors.Store(Store, Compressor(func(w io.Writer) (io.WriteCloser, error) { return &nopCloser{w}, nil })) compressors.Store(Deflate, Compressor(func(w io.Writer) (io.WriteCloser, error) { return newFlateWriter(w), nil })) - decompressors.Store(Store, Decompressor(ioutil.NopCloser)) + decompressors.Store(Store, Decompressor(io.NopCloser)) decompressors.Store(Deflate, Decompressor(newFlateReader)) } diff --git a/src/archive/zip/writer_test.go b/src/archive/zip/writer_test.go index 282f9ec216..2c32eaf4a5 100644 --- a/src/archive/zip/writer_test.go +++ b/src/archive/zip/writer_test.go @@ -301,7 +301,7 @@ func TestWriterFlush(t *testing.T) { } func TestWriterDir(t *testing.T) { - w := NewWriter(ioutil.Discard) + w := NewWriter(io.Discard) dw, err := w.Create("dir/") if err != nil { t.Fatal(err) @@ -380,7 +380,7 @@ func testReadFile(t *testing.T, f *File, wt *WriteTest) { if err != nil { t.Fatal("opening:", err) } - b, err := ioutil.ReadAll(rc) + b, err := io.ReadAll(rc) if err != nil { t.Fatal("reading:", err) } diff --git a/src/archive/zip/zip_test.go b/src/archive/zip/zip_test.go index b3a7caac7f..ead9cd3aab 100644 --- a/src/archive/zip/zip_test.go +++ b/src/archive/zip/zip_test.go @@ -13,7 +13,6 @@ import ( "hash" "internal/testenv" "io" - "io/ioutil" "runtime" "sort" "strings" @@ -620,7 +619,7 @@ func testZip64(t testing.TB, size int64) *rleBuffer { t.Fatal("read:", err) } } - gotEnd, err := ioutil.ReadAll(rc) + gotEnd, err := io.ReadAll(rc) if err != nil { t.Fatal("read end:", err) } |