]> Cypherpunks repositories - gostls13.git/commitdiff
log: use strings.Builder
authorcuiweixie <cuiweixie@gmail.com>
Sun, 4 Sep 2022 10:06:50 +0000 (18:06 +0800)
committerGopher Robot <gobot@golang.org>
Tue, 6 Sep 2022 15:49:33 +0000 (15:49 +0000)
Change-Id: I02c4664f1ba72623a5470e92bbebabb2f4862428
Reviewed-on: https://go-review.googlesource.com/c/go/+/428264
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
src/log/log_test.go

index 938ed423578cb8a8c9d646cd226aff87e7829df8..f2ef165accc976dede1185d33f382429ef3d0df6 100644 (file)
@@ -53,7 +53,7 @@ var tests = []tester{
 
 // Test using Println("hello", 23, "world") or using Printf("hello %d world", 23)
 func testPrint(t *testing.T, flag int, prefix string, pattern string, useFormat bool) {
-       buf := new(bytes.Buffer)
+       buf := new(strings.Builder)
        SetOutput(buf)
        SetFlags(flag)
        SetPrefix(prefix)
@@ -90,7 +90,7 @@ func TestAll(t *testing.T) {
 
 func TestOutput(t *testing.T) {
        const testString = "test"
-       var b bytes.Buffer
+       var b strings.Builder
        l := New(&b, "", 0)
        l.Println(testString)
        if expect := testString + "\n"; b.String() != expect {
@@ -143,7 +143,7 @@ func TestFlagAndPrefixSetting(t *testing.T) {
 }
 
 func TestUTCFlag(t *testing.T) {
-       var b bytes.Buffer
+       var b strings.Builder
        l := New(&b, "Test:", LstdFlags)
        l.SetFlags(Ldate | Ltime | LUTC)
        // 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) {
 }
 
 func TestEmptyPrintCreatesLine(t *testing.T) {
-       var b bytes.Buffer
+       var b strings.Builder
        l := New(&b, "Header:", LstdFlags)
        l.Print()
        l.Println("non-empty")