From a89c3d76ba3c8f75663ebb83ebdbe8432582e9d2 Mon Sep 17 00:00:00 2001 From: cuiweixie Date: Sun, 4 Sep 2022 17:31:08 +0800 Subject: [PATCH] debug: use strings.Builder Change-Id: I59db11212758b478248f34c031501a167335348c Reviewed-on: https://go-review.googlesource.com/c/go/+/428257 Auto-Submit: Ian Lance Taylor Reviewed-by: Ian Lance Taylor Run-TryBot: Ian Lance Taylor Reviewed-by: Robert Griesemer TryBot-Result: Gopher Robot --- src/debug/buildinfo/buildinfo_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/debug/buildinfo/buildinfo_test.go b/src/debug/buildinfo/buildinfo_test.go index 3c7aafa7ff..a0a816be17 100644 --- a/src/debug/buildinfo/buildinfo_test.go +++ b/src/debug/buildinfo/buildinfo_test.go @@ -80,13 +80,13 @@ func TestReadFile(t *testing.T) { cmd := exec.Command(testenv.GoToolPath(t), "build", "-o="+outPath, "-buildmode="+buildmode) cmd.Dir = dir cmd.Env = append(os.Environ(), "GO111MODULE=on", "GOOS="+goos, "GOARCH="+goarch) - stderr := &bytes.Buffer{} + stderr := &strings.Builder{} cmd.Stderr = stderr if err := cmd.Run(); err != nil { if badmodeMsg := badmode(goos, goarch, buildmode); strings.Contains(stderr.String(), badmodeMsg) { t.Skip(badmodeMsg) } - t.Fatalf("failed building test file: %v\n%s", err, stderr.Bytes()) + t.Fatalf("failed building test file: %v\n%s", err, stderr.String()) } return outPath } @@ -106,13 +106,13 @@ func TestReadFile(t *testing.T) { cmd := exec.Command(testenv.GoToolPath(t), "build", "-o="+outPath, "-buildmode="+buildmode) cmd.Dir = pkgDir cmd.Env = append(os.Environ(), "GO111MODULE=off", "GOPATH="+gopathDir, "GOOS="+goos, "GOARCH="+goarch) - stderr := &bytes.Buffer{} + stderr := &strings.Builder{} cmd.Stderr = stderr if err := cmd.Run(); err != nil { if badmodeMsg := badmode(goos, goarch, buildmode); strings.Contains(stderr.String(), badmodeMsg) { t.Skip(badmodeMsg) } - t.Fatalf("failed building test file: %v\n%s", err, stderr.Bytes()) + t.Fatalf("failed building test file: %v\n%s", err, stderr.String()) } return outPath }