Skip to content

Commit 74f0e0c

Browse files
committed
fix: read files from disk
1 parent 6bd937d commit 74f0e0c

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

Diff for: pkg/lint/runner.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func NewRunner(log logutils.Log, cfg *config.Config, args []string, goenv *gouti
6060
return nil, fmt.Errorf("failed to get enabled linters: %w", err)
6161
}
6262

63-
formatter, err := processors.NewFormatter(log, cfg, fileCache, enabledLinters)
63+
formatter, err := processors.NewFormatter(log, cfg, enabledLinters)
6464
if err != nil {
6565
return nil, fmt.Errorf("failed to create formatter: %w", err)
6666
}
@@ -100,7 +100,7 @@ func NewRunner(log logutils.Log, cfg *config.Config, args []string, goenv *gouti
100100

101101
// The fixer still needs to see paths for the issues that are relative to the current directory.
102102
processors.NewFixer(cfg, log, fileCache),
103-
// The fommatter needs to be after the fixer and the last processor that use fileCache.
103+
// The formatter needs to be after the fixer and the last processor that write files.
104104
formatter,
105105

106106
// Now we can modify the issues for output.

Diff for: pkg/result/processors/formatter.go

+3-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"slices"
88

99
"github.com/golangci/golangci-lint/pkg/config"
10-
"github.com/golangci/golangci-lint/pkg/fsutils"
1110
"github.com/golangci/golangci-lint/pkg/goformatters"
1211
"github.com/golangci/golangci-lint/pkg/goformatters/gci"
1312
"github.com/golangci/golangci-lint/pkg/goformatters/gofmt"
@@ -21,17 +20,14 @@ import (
2120
type Formatter struct {
2221
log logutils.Log
2322
cfg *config.Config
24-
fileCache *fsutils.FileCache
2523
formatters []goformatters.Formatter
2624
}
2725

2826
func NewFormatter(log logutils.Log, cfg *config.Config,
29-
fileCache *fsutils.FileCache,
3027
enabledLinters map[string]*linter.Config) (*Formatter, error) {
3128
p := &Formatter{
32-
log: log,
33-
cfg: cfg,
34-
fileCache: fileCache,
29+
log: log,
30+
cfg: cfg,
3531
}
3632

3733
if _, ok := enabledLinters[gofmt.Name]; ok {
@@ -108,7 +104,7 @@ func (p *Formatter) Process(issues []result.Issue) ([]result.Issue, error) {
108104
}
109105

110106
for target := range files {
111-
content, err := p.fileCache.GetFileBytes(target)
107+
content, err := os.ReadFile(target)
112108
if err != nil {
113109
p.log.Warnf("Error reading file %s: %v", target, err)
114110
continue

0 commit comments

Comments
 (0)