Skip to content

Commit 865c4d6

Browse files
committed
chore: isolate changes
1 parent d39fc64 commit 865c4d6

File tree

6 files changed

+25
-18
lines changed

6 files changed

+25
-18
lines changed

internal/cache/cache.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"time"
2323

2424
"github.com/golangci/golangci-lint/internal/renameio"
25-
"github.com/golangci/golangci-lint/internal/robustio"
2625
)
2726

2827
// An ActionID is a cache action key, the hash of a complete description of a
@@ -78,10 +77,6 @@ func (c *Cache) fileName(id [HashSize]byte, key string) string {
7877

7978
var errMissing = errors.New("cache entry not found")
8079

81-
func IsErrMissing(err error) bool {
82-
return errors.Is(err, errMissing)
83-
}
84-
8580
const (
8681
// action entry file is "v1 <hex id> <hex out> <decimal size space-padded to 20 bytes> <unixnano space-padded to 20 bytes>\n"
8782
hexSize = HashSize * 2
@@ -222,16 +217,10 @@ func (c *Cache) GetBytes(id ActionID) ([]byte, Entry, error) {
222217
if err != nil {
223218
return nil, entry, err
224219
}
225-
outputFile, err := c.OutputFile(entry.OutputID)
220+
data, err := c.readFileCGIL(c.OutputFile(entry.OutputID))
226221
if err != nil {
227222
return nil, entry, err
228223
}
229-
230-
data, err := robustio.ReadFile(outputFile)
231-
if err != nil {
232-
return nil, entry, err
233-
}
234-
235224
if sha256.Sum256(data) != entry.OutputID {
236225
return nil, entry, errMissing
237226
}

internal/cache/cache_gcil.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,19 @@
11
package cache
2+
3+
import (
4+
"errors"
5+
6+
"github.com/golangci/golangci-lint/internal/robustio"
7+
)
8+
9+
func IsErrMissing(err error) bool {
10+
return errors.Is(err, errMissing)
11+
}
12+
13+
func (c *Cache) readFileCGIL(outputFile string, err error) ([]byte, error) {
14+
if err != nil {
15+
return nil, err
16+
}
17+
18+
return robustio.ReadFile(outputFile)
19+
}

internal/cache/default.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ import (
1313
"sync"
1414
)
1515

16-
const envGolangciLintCache = "GOLANGCI_LINT_CACHE"
17-
1816
// Default returns the default cache to use.
1917
func Default() (*Cache, error) {
2018
defaultOnce.Do(initDefaultCache)

internal/cache/default_gcil.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
package cache
2+
3+
const envGolangciLintCache = "GOLANGCI_LINT_CACHE"

internal/cache/hash.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ type Hash struct {
3636
// which are still addressed by unsalted SHA256.
3737
var hashSalt []byte
3838

39-
func SetSalt(b []byte) {
40-
hashSalt = b
41-
}
42-
4339
// Subkey returns an action ID corresponding to mixing a parent
4440
// action ID with a string description of the subkey.
4541
func Subkey(parent ActionID, desc string) (ActionID, error) {

internal/cache/hash_gcil.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
package cache
2+
3+
func SetSalt(b []byte) {
4+
hashSalt = b
5+
}

0 commit comments

Comments
 (0)