lintcmd: try using executable's build ID before falling back to hashing it
Closes
@@ -18,6 +18,7 @@ import (
"honnef.co/go/tools/analysis/lint"
"honnef.co/go/tools/config"
+ "honnef.co/go/tools/go/buildid"
"honnef.co/go/tools/go/loader"
"honnef.co/go/tools/internal/cache"
"honnef.co/go/tools/lintcmd/runner"
@@ -39,6 +40,12 @@ func computeSalt() ([]byte, error) {
if err != nil {
return nil, err
}
+
+ if id, err := buildid.ReadFile(p); err == nil {
+ return []byte(id), nil
+ } else {
+ // For some reason we couldn't read the build id from the executable.
+ // Fall back to hashing the entire executable.
f, err := os.Open(p)
if err != nil {
return nil, err
@@ -50,6 +57,7 @@ func computeSalt() ([]byte, error) {
}
return h.Sum(nil), nil
}
+}
func newLinter(cfg config.Config) (*linter, error) {
c, err := cache.Default()
