@@ -122,6 +122,7 @@ func (c *Cache) pkgActionID(pkg *packages.Package, mode HashMode) (cache.ActionI
122
122
if err != nil {
123
123
return cache.ActionID {}, fmt .Errorf ("failed to make a hash: %w" , err )
124
124
}
125
+
125
126
fmt .Fprintf (key , "pkgpath %s\n " , pkg .PkgPath )
126
127
fmt .Fprintf (key , "pkghash %s\n " , hash )
127
128
@@ -138,24 +139,28 @@ func (c *Cache) packageHash(pkg *packages.Package, mode HashMode) (string, error
138
139
if _ , ok := hashRes [mode ]; ! ok {
139
140
return "" , fmt .Errorf ("no mode %d in hash result" , mode )
140
141
}
142
+
141
143
return hashRes [mode ], nil
142
144
}
143
145
144
- hashRes := hashResults {}
145
-
146
146
key , err := cache .NewHash ("package hash" )
147
147
if err != nil {
148
148
return "" , fmt .Errorf ("failed to make a hash: %w" , err )
149
149
}
150
150
151
+ hashRes := hashResults {}
152
+
151
153
fmt .Fprintf (key , "pkgpath %s\n " , pkg .PkgPath )
154
+
152
155
for _ , f := range pkg .CompiledGoFiles {
153
156
h , fErr := c .fileHash (f )
154
157
if fErr != nil {
155
158
return "" , fmt .Errorf ("failed to calculate file %s hash: %w" , f , fErr )
156
159
}
160
+
157
161
fmt .Fprintf (key , "file %s %x\n " , f , h )
158
162
}
163
+
159
164
curSum := key .Sum ()
160
165
hashRes [HashModeNeedOnlySelf ] = hex .EncodeToString (curSum [:])
161
166
@@ -175,6 +180,7 @@ func (c *Cache) packageHash(pkg *packages.Package, mode HashMode) (string, error
175
180
if err := c .computeDepsHash (HashModeNeedAllDeps , imps , key ); err != nil {
176
181
return "" , err
177
182
}
183
+
178
184
curSum = key .Sum ()
179
185
hashRes [HashModeNeedAllDeps ] = hex .EncodeToString (curSum [:])
180
186
@@ -183,6 +189,7 @@ func (c *Cache) packageHash(pkg *packages.Package, mode HashMode) (string, error
183
189
}
184
190
185
191
c .pkgHashes .Store (pkg , hashRes )
192
+
186
193
return hashRes [mode ], nil
187
194
}
188
195
0 commit comments