Skip to content

Commit e3885c4

Browse files
cuiweixiegopherbot
authored andcommitted
log: use strings.Builder
Change-Id: I02c4664f1ba72623a5470e92bbebabb2f4862428 Reviewed-on: https://go-review.googlesource.com/c/go/+/428264 Reviewed-by: Robert Griesemer <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 7c47c97 commit e3885c4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/log/log_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ var tests = []tester{
5353

5454
// Test using Println("hello", 23, "world") or using Printf("hello %d world", 23)
5555
func testPrint(t *testing.T, flag int, prefix string, pattern string, useFormat bool) {
56-
buf := new(bytes.Buffer)
56+
buf := new(strings.Builder)
5757
SetOutput(buf)
5858
SetFlags(flag)
5959
SetPrefix(prefix)
@@ -90,7 +90,7 @@ func TestAll(t *testing.T) {
9090

9191
func TestOutput(t *testing.T) {
9292
const testString = "test"
93-
var b bytes.Buffer
93+
var b strings.Builder
9494
l := New(&b, "", 0)
9595
l.Println(testString)
9696
if expect := testString + "\n"; b.String() != expect {
@@ -143,7 +143,7 @@ func TestFlagAndPrefixSetting(t *testing.T) {
143143
}
144144

145145
func TestUTCFlag(t *testing.T) {
146-
var b bytes.Buffer
146+
var b strings.Builder
147147
l := New(&b, "Test:", LstdFlags)
148148
l.SetFlags(Ldate | Ltime | LUTC)
149149
// Verify a log message looks right in the right time zone. Quantize to the second only.
@@ -167,7 +167,7 @@ func TestUTCFlag(t *testing.T) {
167167
}
168168

169169
func TestEmptyPrintCreatesLine(t *testing.T) {
170-
var b bytes.Buffer
170+
var b strings.Builder
171171
l := New(&b, "Header:", LstdFlags)
172172
l.Print()
173173
l.Println("non-empty")

0 commit comments

Comments
 (0)