aboutsummaryrefslogtreecommitdiff
path: root/src/io
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2020-10-16 00:49:02 -0400
committerRuss Cox <rsc@golang.org>2020-10-20 18:41:18 +0000
commit1b09d430678d4a6f73b2443463d11f75851aba8a (patch)
treefec040abfc6e1d897f8dcdbb856e77d5bccbb2ca /src/io
parentcb0a0f52e67f128c6ad69027c9a8c7a5caf58446 (diff)
downloadgo-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/io')
-rw-r--r--src/io/example_test.go5
-rw-r--r--src/io/io.go2
-rw-r--r--src/io/multi_test.go11
3 files changed, 8 insertions, 10 deletions
diff --git a/src/io/example_test.go b/src/io/example_test.go
index 4706032429..6d338acd14 100644
--- a/src/io/example_test.go
+++ b/src/io/example_test.go
@@ -8,7 +8,6 @@ import (
"bytes"
"fmt"
"io"
- "io/ioutil"
"log"
"os"
"strings"
@@ -141,7 +140,7 @@ func ExampleTeeReader() {
r = io.TeeReader(r, os.Stdout)
// Everything read from r will be copied to stdout.
- ioutil.ReadAll(r)
+ io.ReadAll(r)
// Output:
// some io.Reader stream to be read
@@ -245,7 +244,7 @@ func ExamplePipe() {
func ExampleReadAll() {
r := strings.NewReader("Go is a general-purpose language designed with systems programming in mind.")
- b, err := ioutil.ReadAll(r)
+ b, err := io.ReadAll(r)
if err != nil {
log.Fatal(err)
}
diff --git a/src/io/io.go b/src/io/io.go
index 269ebf6ed0..ffd3cedc25 100644
--- a/src/io/io.go
+++ b/src/io/io.go
@@ -573,7 +573,7 @@ var Discard Writer = discard{}
type discard struct{}
// discard implements ReaderFrom as an optimization so Copy to
-// ioutil.Discard can avoid doing unnecessary work.
+// io.Discard can avoid doing unnecessary work.
var _ ReaderFrom = discard{}
func (discard) Write(p []byte) (int, error) {
diff --git a/src/io/multi_test.go b/src/io/multi_test.go
index f05d5f74ef..909b6d8be2 100644
--- a/src/io/multi_test.go
+++ b/src/io/multi_test.go
@@ -10,7 +10,6 @@ import (
"errors"
"fmt"
. "io"
- "io/ioutil"
"runtime"
"strings"
"testing"
@@ -142,7 +141,7 @@ func testMultiWriter(t *testing.T, sink interface {
}
}
-// writerFunc is an io.Writer implemented by the underlying func.
+// writerFunc is an Writer implemented by the underlying func.
type writerFunc func(p []byte) (int, error)
func (f writerFunc) Write(p []byte) (int, error) {
@@ -196,7 +195,7 @@ func TestMultiReaderCopy(t *testing.T) {
slice := []Reader{strings.NewReader("hello world")}
r := MultiReader(slice...)
slice[0] = nil
- data, err := ioutil.ReadAll(r)
+ data, err := ReadAll(r)
if err != nil || string(data) != "hello world" {
t.Errorf("ReadAll() = %q, %v, want %q, nil", data, err, "hello world")
}
@@ -217,7 +216,7 @@ func TestMultiWriterCopy(t *testing.T) {
}
}
-// readerFunc is an io.Reader implemented by the underlying func.
+// readerFunc is an Reader implemented by the underlying func.
type readerFunc func(p []byte) (int, error)
func (f readerFunc) Read(p []byte) (int, error) {
@@ -261,7 +260,7 @@ func TestMultiReaderFlatten(t *testing.T) {
}
// byteAndEOFReader is a Reader which reads one byte (the underlying
-// byte) and io.EOF at once in its Read call.
+// byte) and EOF at once in its Read call.
type byteAndEOFReader byte
func (b byteAndEOFReader) Read(p []byte) (n int, err error) {
@@ -276,7 +275,7 @@ func (b byteAndEOFReader) Read(p []byte) (n int, err error) {
// This used to yield bytes forever; issue 16795.
func TestMultiReaderSingleByteWithEOF(t *testing.T) {
- got, err := ioutil.ReadAll(LimitReader(MultiReader(byteAndEOFReader('a'), byteAndEOFReader('b')), 10))
+ got, err := ReadAll(LimitReader(MultiReader(byteAndEOFReader('a'), byteAndEOFReader('b')), 10))
if err != nil {
t.Fatal(err)
}