Skip to content

Commit daed3b8

Browse files
committed
chore: add some air
1 parent 120c80e commit daed3b8

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

internal/cache/cache.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ func (c *Cache) pkgActionID(pkg *packages.Package, mode HashMode) (cache.ActionI
122122
if err != nil {
123123
return cache.ActionID{}, fmt.Errorf("failed to make a hash: %w", err)
124124
}
125+
125126
fmt.Fprintf(key, "pkgpath %s\n", pkg.PkgPath)
126127
fmt.Fprintf(key, "pkghash %s\n", hash)
127128

@@ -138,24 +139,28 @@ func (c *Cache) packageHash(pkg *packages.Package, mode HashMode) (string, error
138139
if _, ok := hashRes[mode]; !ok {
139140
return "", fmt.Errorf("no mode %d in hash result", mode)
140141
}
142+
141143
return hashRes[mode], nil
142144
}
143145

144-
hashRes := hashResults{}
145-
146146
key, err := cache.NewHash("package hash")
147147
if err != nil {
148148
return "", fmt.Errorf("failed to make a hash: %w", err)
149149
}
150150

151+
hashRes := hashResults{}
152+
151153
fmt.Fprintf(key, "pkgpath %s\n", pkg.PkgPath)
154+
152155
for _, f := range pkg.CompiledGoFiles {
153156
h, fErr := c.fileHash(f)
154157
if fErr != nil {
155158
return "", fmt.Errorf("failed to calculate file %s hash: %w", f, fErr)
156159
}
160+
157161
fmt.Fprintf(key, "file %s %x\n", f, h)
158162
}
163+
159164
curSum := key.Sum()
160165
hashRes[HashModeNeedOnlySelf] = hex.EncodeToString(curSum[:])
161166

@@ -175,6 +180,7 @@ func (c *Cache) packageHash(pkg *packages.Package, mode HashMode) (string, error
175180
if err := c.computeDepsHash(HashModeNeedAllDeps, imps, key); err != nil {
176181
return "", err
177182
}
183+
178184
curSum = key.Sum()
179185
hashRes[HashModeNeedAllDeps] = hex.EncodeToString(curSum[:])
180186

@@ -183,6 +189,7 @@ func (c *Cache) packageHash(pkg *packages.Package, mode HashMode) (string, error
183189
}
184190

185191
c.pkgHashes.Store(pkg, hashRes)
192+
186193
return hashRes[mode], nil
187194
}
188195

0 commit comments

Comments
 (0)