Skip to content

Commit 632a706

Browse files
alexandearCrocmagnon
authored andcommitted
refactor: avoid one string to []byte conversion
1 parent 9857857 commit 632a706

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pkg/analyzer/analyzer.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
5959
{
6060
Pos: assignStmt.Pos(),
6161
End: assignStmt.End(),
62-
NewText: []byte(suggested),
62+
NewText: suggested,
6363
},
6464
},
6565
})
@@ -215,10 +215,10 @@ func getRootIdent(pass *analysis.Pass, node ast.Node) *ast.Ident {
215215
}
216216

217217
// render returns the pretty-print of the given node
218-
func render(fset *token.FileSet, x interface{}) (string, error) {
218+
func render(fset *token.FileSet, x interface{}) ([]byte, error) {
219219
var buf bytes.Buffer
220220
if err := printer.Fprint(&buf, fset, x); err != nil {
221-
return "", fmt.Errorf("printing node: %w", err)
221+
return nil, fmt.Errorf("printing node: %w", err)
222222
}
223-
return buf.String(), nil
223+
return buf.Bytes(), nil
224224
}

0 commit comments

Comments
 (0)