Skip to content

Commit ac5265a

Browse files
committed
chore: cut dependencies to internal/go/cache
1 parent 2d38899 commit ac5265a

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

internal/pkgcache/pkgcache.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,3 +226,12 @@ func (c *Cache) packageHash(pkg *packages.Package, mode HashMode) (string, error
226226
c.pkgHashes.Store(pkg, hashRes)
227227
return hashRes[mode], nil
228228
}
229+
230+
func SetSalt(b *bytes.Buffer) {
231+
cache.SetSalt(b.Bytes())
232+
}
233+
234+
func DefaultDir() string {
235+
cacheDir, _ := cache.DefaultDir()
236+
return cacheDir
237+
}

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/go/cache"
10+
"github.com/golangci/golangci-lint/internal/pkgcache"
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, _ := cache.DefaultDir()
54+
cacheDir := pkgcache.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, _ := cache.DefaultDir()
64+
cacheDir := pkgcache.DefaultDir()
6565

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

pkg/commands/run.go

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

30-
"github.com/golangci/golangci-lint/internal/go/cache"
3130
"github.com/golangci/golangci-lint/internal/pkgcache"
3231
"github.com/golangci/golangci-lint/pkg/config"
3332
"github.com/golangci/golangci-lint/pkg/exitcodes"
@@ -640,7 +639,7 @@ func initHashSalt(version string, cfg *config.Config) error {
640639

641640
b := bytes.NewBuffer(binSalt)
642641
b.Write(configSalt)
643-
cache.SetSalt(b.Bytes())
642+
pkgcache.SetSalt(b)
644643
return nil
645644
}
646645

0 commit comments

Comments
 (0)