aboutsummaryrefslogtreecommitdiff
path: root/src/text
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/text
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/text')
-rw-r--r--src/text/tabwriter/tabwriter_test.go11
-rw-r--r--src/text/template/exec_test.go8
2 files changed, 9 insertions, 10 deletions
diff --git a/src/text/tabwriter/tabwriter_test.go b/src/text/tabwriter/tabwriter_test.go
index 6a97d4c427..a51358dbed 100644
--- a/src/text/tabwriter/tabwriter_test.go
+++ b/src/text/tabwriter/tabwriter_test.go
@@ -8,7 +8,6 @@ import (
"bytes"
"fmt"
"io"
- "io/ioutil"
"testing"
. "text/tabwriter"
)
@@ -664,7 +663,7 @@ func BenchmarkTable(b *testing.B) {
b.Run("new", func(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
- w := NewWriter(ioutil.Discard, 4, 4, 1, ' ', 0) // no particular reason for these settings
+ w := NewWriter(io.Discard, 4, 4, 1, ' ', 0) // no particular reason for these settings
// Write the line h times.
for j := 0; j < h; j++ {
w.Write(line)
@@ -675,7 +674,7 @@ func BenchmarkTable(b *testing.B) {
b.Run("reuse", func(b *testing.B) {
b.ReportAllocs()
- w := NewWriter(ioutil.Discard, 4, 4, 1, ' ', 0) // no particular reason for these settings
+ w := NewWriter(io.Discard, 4, 4, 1, ' ', 0) // no particular reason for these settings
for i := 0; i < b.N; i++ {
// Write the line h times.
for j := 0; j < h; j++ {
@@ -696,7 +695,7 @@ func BenchmarkPyramid(b *testing.B) {
b.Run(fmt.Sprintf("%d", x), func(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
- w := NewWriter(ioutil.Discard, 4, 4, 1, ' ', 0) // no particular reason for these settings
+ w := NewWriter(io.Discard, 4, 4, 1, ' ', 0) // no particular reason for these settings
// Write increasing prefixes of that line.
for j := 0; j < x; j++ {
w.Write(line[:j*2])
@@ -718,7 +717,7 @@ func BenchmarkRagged(b *testing.B) {
b.Run(fmt.Sprintf("%d", h), func(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
- w := NewWriter(ioutil.Discard, 4, 4, 1, ' ', 0) // no particular reason for these settings
+ w := NewWriter(io.Discard, 4, 4, 1, ' ', 0) // no particular reason for these settings
// Write the lines in turn h times.
for j := 0; j < h; j++ {
w.Write(lines[j%len(lines)])
@@ -746,7 +745,7 @@ lines
func BenchmarkCode(b *testing.B) {
b.ReportAllocs()
for i := 0; i < b.N; i++ {
- w := NewWriter(ioutil.Discard, 4, 4, 1, ' ', 0) // no particular reason for these settings
+ w := NewWriter(io.Discard, 4, 4, 1, ' ', 0) // no particular reason for these settings
// The code is small, so it's reasonable for the tabwriter user
// to write it all at once, or buffer the writes.
w.Write([]byte(codeSnippet))
diff --git a/src/text/template/exec_test.go b/src/text/template/exec_test.go
index 3309b33e3e..1611ee054f 100644
--- a/src/text/template/exec_test.go
+++ b/src/text/template/exec_test.go
@@ -9,7 +9,7 @@ import (
"errors"
"flag"
"fmt"
- "io/ioutil"
+ "io"
"reflect"
"strings"
"testing"
@@ -1328,7 +1328,7 @@ func TestExecuteGivesExecError(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- err = tmpl.Execute(ioutil.Discard, 0)
+ err = tmpl.Execute(io.Discard, 0)
if err == nil {
t.Fatal("expected error; got none")
}
@@ -1474,7 +1474,7 @@ func TestEvalFieldErrors(t *testing.T) {
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
tmpl := Must(New("tmpl").Parse(tc.src))
- err := tmpl.Execute(ioutil.Discard, tc.value)
+ err := tmpl.Execute(io.Discard, tc.value)
got := "<nil>"
if err != nil {
got = err.Error()
@@ -1491,7 +1491,7 @@ func TestMaxExecDepth(t *testing.T) {
t.Skip("skipping in -short mode")
}
tmpl := Must(New("tmpl").Parse(`{{template "tmpl" .}}`))
- err := tmpl.Execute(ioutil.Discard, nil)
+ err := tmpl.Execute(io.Discard, nil)
got := "<nil>"
if err != nil {
got = err.Error()