Compare commits

..

2 commits

Author SHA1 Message Date
Oleksandr Redko
632a706303 refactor: avoid one string to []byte conversion
Some checks failed
Go / build (push) Has been cancelled
golangci-lint / lint (push) Has been cancelled
Go / coverage (push) Has been cancelled
2024-11-20 15:58:58 +01:00
Oleksandr Redko
98578576b8 chore: format with goimports 2024-11-20 15:56:39 +01:00
4 changed files with 16 additions and 7 deletions

View file

@ -1,3 +1,9 @@
issues: issues:
exclude-dirs: exclude-dirs:
- contrib - contrib
linters:
enable:
- goimports
linters-settings:
goimports:
local-prefixes: "github.com/Crocmagnon/fatcontext"

View file

@ -1,8 +1,9 @@
package main package main
import ( import (
"github.com/Crocmagnon/fatcontext/pkg/analyzer"
"golang.org/x/tools/go/analysis/singlechecker" "golang.org/x/tools/go/analysis/singlechecker"
"github.com/Crocmagnon/fatcontext/pkg/analyzer"
) )
func main() { func main() {

View file

@ -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
} }

View file

@ -1,11 +1,13 @@
package analyzer_test package analyzer_test
import ( import (
"github.com/Crocmagnon/fatcontext/pkg/analyzer"
"golang.org/x/tools/go/analysis/analysistest"
"os" "os"
"path/filepath" "path/filepath"
"testing" "testing"
"golang.org/x/tools/go/analysis/analysistest"
"github.com/Crocmagnon/fatcontext/pkg/analyzer"
) )
func TestAll(t *testing.T) { func TestAll(t *testing.T) {