]> Cypherpunks.ru repositories - gostls13.git/commitdiff
reflect: use strings.Builder
authorcuiweixie <cuiweixie@gmail.com>
Sun, 4 Sep 2022 10:48:51 +0000 (18:48 +0800)
committerGopher Robot <gobot@golang.org>
Wed, 7 Sep 2022 13:56:11 +0000 (13:56 +0000)
Change-Id: Ie100a2a6f272b84fa2da6ac7b64452985242d788
Reviewed-on: https://go-review.googlesource.com/c/go/+/428275
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
src/reflect/all_test.go
src/reflect/set_test.go

index 6cc1c9abad6b30d7500536b12d3a95db192145bc..e07180cd2f88486213c116cbc04bb9d20762856f 100644 (file)
@@ -2085,7 +2085,7 @@ func runSelect(cases []SelectCase, info []caseInfo) (chosen int, recv Value, rec
 
 // fmtSelect formats the information about a single select test.
 func fmtSelect(info []caseInfo) string {
-       var buf bytes.Buffer
+       var buf strings.Builder
        fmt.Fprintf(&buf, "\nselect {\n")
        for i, cas := range info {
                fmt.Fprintf(&buf, "%d: %s", i, cas.desc)
@@ -3705,7 +3705,7 @@ func TestSetLenCap(t *testing.T) {
 }
 
 func TestVariadic(t *testing.T) {
-       var b bytes.Buffer
+       var b strings.Builder
        V := ValueOf
 
        b.Reset()
index 9ce0e09b824213037e8fa2a9ed929d79a41a70b2..028c051cfbd5fbb03c925fa8a2a68433a1356e52 100644 (file)
@@ -10,6 +10,7 @@ import (
        "go/token"
        "io"
        . "reflect"
+       "strings"
        "testing"
        "unsafe"
 )
@@ -141,7 +142,7 @@ func TestImplicitSendConversion(t *testing.T) {
 func TestImplicitCallConversion(t *testing.T) {
        // Arguments must be assignable to parameter types.
        fv := ValueOf(io.WriteString)
-       b := new(bytes.Buffer)
+       b := new(strings.Builder)
        fv.Call([]Value{ValueOf(b), ValueOf("hello world")})
        if b.String() != "hello world" {
                t.Errorf("After call: string=%q want %q", b.String(), "hello world")