Преглед изворни кода

Use buffer as a var instead of NewBuffer(nil). (#312)

Alexey Alexandrov пре 7 година
родитељ
комит
35174474cc
No account linked to committer's email address
4 измењених фајлова са 14 додато и 14 уклоњено
  1. 2
    2
      internal/report/report_test.go
  2. 2
    2
      internal/report/source_test.go
  3. 7
    7
      profile/profile_test.go
  4. 3
    3
      profile/proto_test.go

+ 2
- 2
internal/report/report_test.go Прегледај датотеку

@@ -68,8 +68,8 @@ func TestSource(t *testing.T) {
68 68
 			want: path + "source.dot",
69 69
 		},
70 70
 	} {
71
-		b := bytes.NewBuffer(nil)
72
-		if err := Generate(b, tc.rpt, &binutils.Binutils{}); err != nil {
71
+		var b bytes.Buffer
72
+		if err := Generate(&b, tc.rpt, &binutils.Binutils{}); err != nil {
73 73
 			t.Fatalf("%s: %v", tc.want, err)
74 74
 		}
75 75
 

+ 2
- 2
internal/report/source_test.go Прегледај датотеку

@@ -25,8 +25,8 @@ func TestWebList(t *testing.T) {
25 25
 		SampleValue:  func(v []int64) int64 { return v[1] },
26 26
 		SampleUnit:   cpu.SampleType[1].Unit,
27 27
 	})
28
-	buf := bytes.NewBuffer(nil)
29
-	if err := Generate(buf, rpt, &binutils.Binutils{}); err != nil {
28
+	var buf bytes.Buffer
29
+	if err := Generate(&buf, rpt, &binutils.Binutils{}); err != nil {
30 30
 		t.Fatalf("could not generate weblist: %v", err)
31 31
 	}
32 32
 	output := buf.String()

+ 7
- 7
profile/profile_test.go Прегледај датотеку

@@ -73,11 +73,11 @@ func TestParse(t *testing.T) {
73 73
 		}
74 74
 
75 75
 		// Reencode and decode.
76
-		bw := bytes.NewBuffer(nil)
77
-		if err := p.Write(bw); err != nil {
76
+		var bw bytes.Buffer
77
+		if err := p.Write(&bw); err != nil {
78 78
 			t.Fatalf("%s: %v", source, err)
79 79
 		}
80
-		if p, err = Parse(bw); err != nil {
80
+		if p, err = Parse(&bw); err != nil {
81 81
 			t.Fatalf("%s: %v", source, err)
82 82
 		}
83 83
 		js2 := p.String()
@@ -111,10 +111,10 @@ func TestParseError(t *testing.T) {
111 111
 func TestParseConcatentated(t *testing.T) {
112 112
 	prof := testProfile1.Copy()
113 113
 	// Write the profile twice to buffer to create concatented profile.
114
-	buf := bytes.NewBuffer(nil)
115
-	prof.Write(buf)
116
-	prof.Write(buf)
117
-	_, err := Parse(buf)
114
+	var buf bytes.Buffer
115
+	prof.Write(&buf)
116
+	prof.Write(&buf)
117
+	_, err := Parse(&buf)
118 118
 	if err == nil {
119 119
 		t.Fatalf("got nil, want error")
120 120
 	}

+ 3
- 3
profile/proto_test.go Прегледај датотеку

@@ -151,9 +151,9 @@ var all = &Profile{
151 151
 
152 152
 func TestMarshalUnmarshal(t *testing.T) {
153 153
 	// Write the profile, parse it, and ensure they're equal.
154
-	buf := bytes.NewBuffer(nil)
155
-	all.Write(buf)
156
-	all2, err := Parse(buf)
154
+	var buf bytes.Buffer
155
+	all.Write(&buf)
156
+	all2, err := Parse(&buf)
157 157
 	if err != nil {
158 158
 		t.Fatal(err)
159 159
 	}