runtime: use strings.Builder

Change-Id: I9274d36ca983fdf59088b71a97b139ea262370dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/428276
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
This commit is contained in:
cuiweixie 2022-09-04 18:53:24 +08:00 committed by Daniel Martí
parent 6375f508a8
commit f4bf9bceac
4 changed files with 6 additions and 9 deletions

View File

@ -5,7 +5,6 @@
package runtime_test
import (
"bytes"
"go/ast"
"go/build"
"go/importer"
@ -180,7 +179,7 @@ func (v *Visitor) checkAddr(n ast.Node) {
}
func (v *Visitor) print(n ast.Node) string {
var b bytes.Buffer
var b strings.Builder
printer.Fprint(&b, v.fset, n)
return b.String()
}

View File

@ -23,7 +23,6 @@
package runtime_test
import (
"bytes"
"fmt"
"regexp"
"runtime"
@ -94,7 +93,7 @@ func TestDebugLogInterleaving(t *testing.T) {
}
wg.Done()
}()
var want bytes.Buffer
var want strings.Builder
for i := 0; i < 1000; i++ {
runtime.Dlog().I(i).End()
fmt.Fprintf(&want, "[] %d\n", i)
@ -122,7 +121,7 @@ func TestDebugLogWraparound(t *testing.T) {
runtime.ResetDebugLog()
var longString = strings.Repeat("a", 128)
var want bytes.Buffer
var want strings.Builder
for i, j := 0, 0; j < 2*runtime.DebugLogBytes; i, j = i+1, j+len(longString) {
runtime.Dlog().I(i).S(longString).End()
fmt.Fprintf(&want, "[] %d %s\n", i, longString)

View File

@ -93,8 +93,8 @@ func TestCtrlHandler(t *testing.T) {
// run test program
cmd = exec.Command(exe)
var stdout bytes.Buffer
var stderr bytes.Buffer
var stdout strings.Builder
var stderr strings.Builder
cmd.Stdout = &stdout
cmd.Stderr = &stderr
inPipe, err := cmd.StdinPipe()

View File

@ -5,7 +5,6 @@
package runtime_test
import (
"bytes"
"fmt"
"reflect"
"regexp"
@ -778,7 +777,7 @@ func TestTracebackSystemstack(t *testing.T) {
// and that we see TestTracebackSystemstack.
countIn, countOut := 0, 0
frames := CallersFrames(pcs)
var tb bytes.Buffer
var tb strings.Builder
for {
frame, more := frames.Next()
fmt.Fprintf(&tb, "\n%s+0x%x %s:%d", frame.Function, frame.PC-frame.Entry, frame.File, frame.Line)