aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2018-03-26 06:56:39 +0000
committerBrad Fitzpatrick <bradfitz@golang.org>2018-03-26 23:05:53 +0000
commit48db2c01b42d959f2d8fa0c24d853bdb6100cf8a (patch)
treec80a885e1971c4114d33c25e905def159be7f73c /src/testing
parentf0eca373beb94763b71dadcf6504a95a3797dcbb (diff)
downloadgo-48db2c01b42d959f2d8fa0c24d853bdb6100cf8a.tar.xz
all: use strings.Builder instead of bytes.Buffer where appropriate
I grepped for "bytes.Buffer" and "buf.String" and mostly ignored test files. I skipped a few on purpose and probably missed a few others, but otherwise I think this should be most of them. Updates #18990 Change-Id: I5a6ae4296b87b416d8da02d7bfaf981d8cc14774 Reviewed-on: https://go-review.googlesource.com/102479 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/example.go3
-rw-r--r--src/testing/testing.go2
2 files changed, 2 insertions, 3 deletions
diff --git a/src/testing/example.go b/src/testing/example.go
index b9955500e6..f4beb76f5f 100644
--- a/src/testing/example.go
+++ b/src/testing/example.go
@@ -5,7 +5,6 @@
package testing
import (
- "bytes"
"fmt"
"io"
"os"
@@ -72,7 +71,7 @@ func runExample(eg InternalExample) (ok bool) {
os.Stdout = w
outC := make(chan string)
go func() {
- var buf bytes.Buffer
+ var buf strings.Builder
_, err := io.Copy(&buf, r)
r.Close()
if err != nil {
diff --git a/src/testing/testing.go b/src/testing/testing.go
index 27d0de7728..7e936f0fca 100644
--- a/src/testing/testing.go
+++ b/src/testing/testing.go
@@ -376,7 +376,7 @@ func (c *common) decorate(s string) string {
file = "???"
line = 1
}
- buf := new(bytes.Buffer)
+ buf := new(strings.Builder)
// Every line is indented at least one tab.
buf.WriteByte('\t')
fmt.Fprintf(buf, "%s:%d: ", file, line)