mirror of
https://github.com/Crocmagnon/fatcontext.git
synced 2024-11-21 15:38:08 +01:00
refactor: avoid one string to []byte conversion
This commit is contained in:
parent
98578576b8
commit
632a706303
1 changed files with 4 additions and 4 deletions
|
@ -59,7 +59,7 @@ func run(pass *analysis.Pass) (interface{}, error) {
|
||||||
{
|
{
|
||||||
Pos: assignStmt.Pos(),
|
Pos: assignStmt.Pos(),
|
||||||
End: assignStmt.End(),
|
End: assignStmt.End(),
|
||||||
NewText: []byte(suggested),
|
NewText: suggested,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -215,10 +215,10 @@ func getRootIdent(pass *analysis.Pass, node ast.Node) *ast.Ident {
|
||||||
}
|
}
|
||||||
|
|
||||||
// render returns the pretty-print of the given node
|
// render returns the pretty-print of the given node
|
||||||
func render(fset *token.FileSet, x interface{}) (string, error) {
|
func render(fset *token.FileSet, x interface{}) ([]byte, error) {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
if err := printer.Fprint(&buf, fset, x); err != nil {
|
if err := printer.Fprint(&buf, fset, x); err != nil {
|
||||||
return "", fmt.Errorf("printing node: %w", err)
|
return nil, fmt.Errorf("printing node: %w", err)
|
||||||
}
|
}
|
||||||
return buf.String(), nil
|
return buf.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue