build: fix linter install on windows (#24523)

This commit is contained in:
ligi 2022-03-15 10:24:45 +01:00 committed by GitHub
parent fb2ae8e995
commit a6bf2487d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View File

@ -336,12 +336,17 @@ func downloadLinter(cachedir string) string {
csdb := build.MustLoadChecksums("build/checksums.txt") csdb := build.MustLoadChecksums("build/checksums.txt")
arch := runtime.GOARCH arch := runtime.GOARCH
if arch == "arm" { ext := ".tar.gz"
if runtime.GOOS == "windows" {
ext = ".zip"
}
if arch == "arm" {
arch += "v" + os.Getenv("GOARM") arch += "v" + os.Getenv("GOARM")
} }
base := fmt.Sprintf("golangci-lint-%s-%s-%s", version, runtime.GOOS, arch) base := fmt.Sprintf("golangci-lint-%s-%s-%s", version, runtime.GOOS, arch)
url := fmt.Sprintf("https://github.com/golangci/golangci-lint/releases/download/v%s/%s.tar.gz", version, base) url := fmt.Sprintf("https://github.com/golangci/golangci-lint/releases/download/v%s/%s%s", version, base, ext)
archivePath := filepath.Join(cachedir, base+".tar.gz") archivePath := filepath.Join(cachedir, base+ext)
if err := csdb.DownloadFile(url, archivePath); err != nil { if err := csdb.DownloadFile(url, archivePath); err != nil {
log.Fatal(err) log.Fatal(err)
} }

View File

@ -58,7 +58,7 @@ func (db *ChecksumDB) Verify(path string) error {
} }
fileHash := hex.EncodeToString(h.Sum(nil)) fileHash := hex.EncodeToString(h.Sum(nil))
if !db.findHash(filepath.Base(path), fileHash) { if !db.findHash(filepath.Base(path), fileHash) {
return fmt.Errorf("invalid file hash %s", fileHash) return fmt.Errorf("invalid file hash %s for %s", fileHash, filepath.Base(path))
} }
return nil return nil
} }