1
0
mirror of https://github.com/golang/go synced 2024-11-05 17:36:15 -07:00

cmd/fix: use strings.Builder

Change-Id: I761766e147202970f82ce804dbaf5d491508995c
Reviewed-on: https://go-review.googlesource.com/c/go/+/428289
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
This commit is contained in:
cuiweixie 2022-09-04 20:08:30 +08:00 committed by Gopher Robot
parent 866fbb67d0
commit 9c147cc617

View File

@ -141,7 +141,7 @@ func gofmtFile(f *ast.File) ([]byte, error) {
func processFile(filename string, useStdin bool) error { func processFile(filename string, useStdin bool) error {
var f *os.File var f *os.File
var err error var err error
var fixlog bytes.Buffer var fixlog strings.Builder
if useStdin { if useStdin {
f = os.Stdin f = os.Stdin
@ -240,7 +240,7 @@ func processFile(filename string, useStdin bool) error {
} }
func gofmt(n any) string { func gofmt(n any) string {
var gofmtBuf bytes.Buffer var gofmtBuf strings.Builder
if err := format.Node(&gofmtBuf, fset, n); err != nil { if err := format.Node(&gofmtBuf, fset, n); err != nil {
return "<" + err.Error() + ">" return "<" + err.Error() + ">"
} }