Skip to content

Commit bd12b8a

Browse files
committed
code opt: replace bytes.Buffer with strings.Builder
1 parent 68924d0 commit bd12b8a

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

โ€Žreflection/server_reflection.goโ€Ž

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package reflection
22

33
import (
4-
"bytes"
54
"context"
65
"encoding/json"
76
"fmt"
@@ -52,7 +51,7 @@ type (s *{{$name}}) {{.Name}}(ctx context.Context, arg *{{.ReqName}}, reply *{{.
5251

5352
func (si ServiceInfo) String() string {
5453
tpl := template.Must(template.New("service").Parse(siTemplate))
55-
var buf bytes.Buffer
54+
var buf strings.Builder
5655
_ = tpl.Execute(&buf, si)
5756
return buf.String()
5857
}
@@ -160,7 +159,7 @@ func (r *Reflection) GetService(ctx context.Context, s string, reply *string) er
160159
}
161160

162161
func (r *Reflection) GetServices(ctx context.Context, s string, reply *string) error {
163-
var buf bytes.Buffer
162+
var buf strings.Builder
164163

165164
pkg := `package `
166165

0 commit comments

Comments
ย (0)