Skip to content

Commit 569d5d7

Browse files
committed
chore: rename pkcache to cache
1 parent ac5265a commit 569d5d7

File tree

8 files changed

+22
-22
lines changed

8 files changed

+22
-22
lines changed

internal/pkgcache/pkgcache.go renamed to internal/cache/cache.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package pkgcache
1+
package cache
22

33
import (
44
"bytes"

pkg/commands/cache.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77

88
"github.com/spf13/cobra"
99

10-
"github.com/golangci/golangci-lint/internal/pkgcache"
10+
"github.com/golangci/golangci-lint/internal/cache"
1111
"github.com/golangci/golangci-lint/pkg/fsutils"
1212
"github.com/golangci/golangci-lint/pkg/logutils"
1313
)
@@ -51,7 +51,7 @@ func newCacheCommand() *cacheCommand {
5151
}
5252

5353
func (*cacheCommand) executeClean(_ *cobra.Command, _ []string) error {
54-
cacheDir := pkgcache.DefaultDir()
54+
cacheDir := cache.DefaultDir()
5555

5656
if err := os.RemoveAll(cacheDir); err != nil {
5757
return fmt.Errorf("failed to remove dir %s: %w", cacheDir, err)
@@ -61,7 +61,7 @@ func (*cacheCommand) executeClean(_ *cobra.Command, _ []string) error {
6161
}
6262

6363
func (*cacheCommand) executeStatus(_ *cobra.Command, _ []string) {
64-
cacheDir := pkgcache.DefaultDir()
64+
cacheDir := cache.DefaultDir()
6565

6666
_, _ = fmt.Fprintf(logutils.StdOut, "Dir: %s\n", cacheDir)
6767

pkg/commands/run.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
"golang.org/x/exp/maps"
2828
"gopkg.in/yaml.v3"
2929

30-
"github.com/golangci/golangci-lint/internal/pkgcache"
30+
"github.com/golangci/golangci-lint/internal/cache"
3131
"github.com/golangci/golangci-lint/pkg/config"
3232
"github.com/golangci/golangci-lint/pkg/exitcodes"
3333
"github.com/golangci/golangci-lint/pkg/fsutils"
@@ -208,7 +208,7 @@ func (c *runCommand) preRunE(_ *cobra.Command, args []string) error {
208208

209209
sw := timeutils.NewStopwatch("pkgcache", c.log.Child(logutils.DebugKeyStopwatch))
210210

211-
pkgCache, err := pkgcache.NewCache(sw, c.log.Child(logutils.DebugKeyPkgCache))
211+
pkgCache, err := cache.NewCache(sw, c.log.Child(logutils.DebugKeyPkgCache))
212212
if err != nil {
213213
return fmt.Errorf("failed to build packages cache: %w", err)
214214
}
@@ -639,7 +639,7 @@ func initHashSalt(version string, cfg *config.Config) error {
639639

640640
b := bytes.NewBuffer(binSalt)
641641
b.Write(configSalt)
642-
pkgcache.SetSalt(b)
642+
cache.SetSalt(b)
643643
return nil
644644
}
645645

pkg/goanalysis/runner.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import (
2121
"golang.org/x/tools/go/analysis"
2222
"golang.org/x/tools/go/packages"
2323

24+
"github.com/golangci/golangci-lint/internal/cache"
2425
"github.com/golangci/golangci-lint/internal/errorutil"
25-
"github.com/golangci/golangci-lint/internal/pkgcache"
2626
"github.com/golangci/golangci-lint/pkg/goanalysis/load"
2727
"github.com/golangci/golangci-lint/pkg/logutils"
2828
"github.com/golangci/golangci-lint/pkg/timeutils"
@@ -52,15 +52,15 @@ type Diagnostic struct {
5252
type runner struct {
5353
log logutils.Log
5454
prefix string // ensure unique analyzer names
55-
pkgCache *pkgcache.Cache
55+
pkgCache *cache.Cache
5656
loadGuard *load.Guard
5757
loadMode LoadMode
5858
passToPkg map[*analysis.Pass]*packages.Package
5959
passToPkgGuard sync.Mutex
6060
sw *timeutils.Stopwatch
6161
}
6262

63-
func newRunner(prefix string, logger logutils.Log, pkgCache *pkgcache.Cache, loadGuard *load.Guard,
63+
func newRunner(prefix string, logger logutils.Log, pkgCache *cache.Cache, loadGuard *load.Guard,
6464
loadMode LoadMode, sw *timeutils.Stopwatch,
6565
) *runner {
6666
return &runner{

pkg/goanalysis/runner_action.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313
"golang.org/x/tools/go/packages"
1414
"golang.org/x/tools/go/types/objectpath"
1515

16+
"github.com/golangci/golangci-lint/internal/cache"
1617
"github.com/golangci/golangci-lint/internal/errorutil"
17-
"github.com/golangci/golangci-lint/internal/pkgcache"
1818
"github.com/golangci/golangci-lint/pkg/goanalysis/pkgerrors"
1919
)
2020

@@ -328,14 +328,14 @@ func (act *action) persistFactsToCache() error {
328328
factsCacheDebugf("Caching %d facts for package %q and analyzer %s", len(facts), act.pkg.Name, act.a.Name)
329329

330330
key := fmt.Sprintf("%s/facts", analyzer.Name)
331-
return act.r.pkgCache.Put(act.pkg, pkgcache.HashModeNeedAllDeps, key, facts)
331+
return act.r.pkgCache.Put(act.pkg, cache.HashModeNeedAllDeps, key, facts)
332332
}
333333

334334
func (act *action) loadPersistedFacts() bool {
335335
var facts []Fact
336336
key := fmt.Sprintf("%s/facts", act.a.Name)
337-
if err := act.r.pkgCache.Get(act.pkg, pkgcache.HashModeNeedAllDeps, key, &facts); err != nil {
338-
if !errors.Is(err, pkgcache.ErrMissing) && !errors.Is(err, io.EOF) {
337+
if err := act.r.pkgCache.Get(act.pkg, cache.HashModeNeedAllDeps, key, &facts); err != nil {
338+
if !errors.Is(err, cache.ErrMissing) && !errors.Is(err, io.EOF) {
339339
act.r.log.Warnf("Failed to get persisted facts: %s", err)
340340
}
341341

pkg/goanalysis/runners.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"golang.org/x/tools/go/analysis"
1313
"golang.org/x/tools/go/packages"
1414

15-
"github.com/golangci/golangci-lint/internal/pkgcache"
15+
"github.com/golangci/golangci-lint/internal/cache"
1616
"github.com/golangci/golangci-lint/pkg/goanalysis/pkgerrors"
1717
"github.com/golangci/golangci-lint/pkg/lint/linter"
1818
"github.com/golangci/golangci-lint/pkg/logutils"
@@ -163,7 +163,7 @@ func saveIssuesToCache(allPkgs []*packages.Package, pkgsFromCache map[*packages.
163163
}
164164

165165
atomic.AddInt64(&savedIssuesCount, int64(len(encodedIssues)))
166-
if err := lintCtx.PkgCache.Put(pkg, pkgcache.HashModeNeedAllDeps, lintResKey, encodedIssues); err != nil {
166+
if err := lintCtx.PkgCache.Put(pkg, cache.HashModeNeedAllDeps, lintResKey, encodedIssues); err != nil {
167167
lintCtx.Log.Infof("Failed to save package %s issues (%d) to cache: %s", pkg, len(pkgIssues), err)
168168
} else {
169169
issuesCacheDebugf("Saved package %s issues (%d) to cache", pkg, len(pkgIssues))
@@ -212,7 +212,7 @@ func loadIssuesFromCache(pkgs []*packages.Package, lintCtx *linter.Context,
212212
defer wg.Done()
213213
for pkg := range pkgCh {
214214
var pkgIssues []EncodingIssue
215-
err := lintCtx.PkgCache.Get(pkg, pkgcache.HashModeNeedAllDeps, lintResKey, &pkgIssues)
215+
err := lintCtx.PkgCache.Get(pkg, cache.HashModeNeedAllDeps, lintResKey, &pkgIssues)
216216
cacheRes := pkgToCacheRes[pkg]
217217
cacheRes.loadErr = err
218218
if err != nil {

pkg/lint/context.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"fmt"
66

7-
"github.com/golangci/golangci-lint/internal/pkgcache"
7+
"github.com/golangci/golangci-lint/internal/cache"
88
"github.com/golangci/golangci-lint/pkg/config"
99
"github.com/golangci/golangci-lint/pkg/exitcodes"
1010
"github.com/golangci/golangci-lint/pkg/fsutils"
@@ -19,13 +19,13 @@ type ContextBuilder struct {
1919
pkgLoader *PackageLoader
2020

2121
fileCache *fsutils.FileCache
22-
pkgCache *pkgcache.Cache
22+
pkgCache *cache.Cache
2323

2424
loadGuard *load.Guard
2525
}
2626

2727
func NewContextBuilder(cfg *config.Config, pkgLoader *PackageLoader,
28-
fileCache *fsutils.FileCache, pkgCache *pkgcache.Cache, loadGuard *load.Guard,
28+
fileCache *fsutils.FileCache, pkgCache *cache.Cache, loadGuard *load.Guard,
2929
) *ContextBuilder {
3030
return &ContextBuilder{
3131
cfg: cfg,

pkg/lint/linter/context.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55

66
"golang.org/x/tools/go/packages"
77

8-
"github.com/golangci/golangci-lint/internal/pkgcache"
8+
"github.com/golangci/golangci-lint/internal/cache"
99
"github.com/golangci/golangci-lint/pkg/config"
1010
"github.com/golangci/golangci-lint/pkg/fsutils"
1111
"github.com/golangci/golangci-lint/pkg/goanalysis/load"
@@ -24,7 +24,7 @@ type Context struct {
2424
FileCache *fsutils.FileCache
2525
Log logutils.Log
2626

27-
PkgCache *pkgcache.Cache
27+
PkgCache *cache.Cache
2828
LoadGuard *load.Guard
2929
}
3030

0 commit comments

Comments
 (0)