Skip to content

Commit 89b7513

Browse files
committed
refactor gofumpt to get rid of shazow/go-diff dep
1 parent 7aabaf5 commit 89b7513

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ require (
7272
github.com/ryanrolds/sqlclosecheck v0.3.0
7373
github.com/sanposhiho/wastedassign/v2 v2.0.6
7474
github.com/securego/gosec/v2 v2.9.6
75-
github.com/shazow/go-diff v0.0.0-20160112020656-b6b7b6733b8c
7675
github.com/shirou/gopsutil/v3 v3.22.1
7776
github.com/sirupsen/logrus v1.8.1
7877
github.com/sivchari/containedctx v1.0.1

go.sum

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/golinters/goanalysis/suggested_fixes.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ func createPatchAndExtractIssues(lintCtx *linter.Context, linterName, filename s
9090
B: difflib.SplitLines(string(dst)),
9191
Context: 3,
9292
}
93-
9493
if err := difflib.WriteUnifiedDiff(&out, d); err != nil {
9594
return nil, errors.Wrap(err, "can't create diff")
9695
}

pkg/golinters/gofumpt.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"sync"
88

99
"github.com/pkg/errors"
10-
"github.com/shazow/go-diff/difflib"
10+
"github.com/pmezard/go-difflib/difflib"
1111
"golang.org/x/tools/go/analysis"
1212
"mvdan.cc/gofumpt/format"
1313

@@ -29,7 +29,6 @@ func NewGofumpt() *goanalysis.Linter {
2929

3030
var mu sync.Mutex
3131
var resIssues []goanalysis.Issue
32-
differ := difflib.New()
3332

3433
analyzer := &analysis.Analyzer{
3534
Name: gofumptName,
@@ -75,9 +74,13 @@ func NewGofumpt() *goanalysis.Linter {
7574
return nil, fmt.Errorf("error while running gofumpt: %w", err)
7675
}
7776

78-
err = differ.Diff(&out, bytes.NewReader(input), bytes.NewReader(output))
79-
if err != nil {
80-
return nil, fmt.Errorf("error while running gofumpt: %w", err)
77+
d := difflib.UnifiedDiff{
78+
A: difflib.SplitLines(string(input)),
79+
B: difflib.SplitLines(string(output)),
80+
Context: 3,
81+
}
82+
if err := difflib.WriteUnifiedDiff(&out, d); err != nil {
83+
return nil, errors.Wrap(err, "can't create diff")
8184
}
8285

8386
diff := out.String()

0 commit comments

Comments
 (0)