From f8e2104b52ce99c5977017045539ef7c18871c24 Mon Sep 17 00:00:00 2001 From: ligi Date: Tue, 15 Mar 2022 10:24:45 +0100 Subject: [PATCH] build: fix linter install on windows (#24523) --- build/ci.go | 11 ++++++++--- internal/build/download.go | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/build/ci.go b/build/ci.go index 9ab0680591..85251a3cab 100644 --- a/build/ci.go +++ b/build/ci.go @@ -342,12 +342,17 @@ func downloadLinter(cachedir string) string { csdb := build.MustLoadChecksums("build/checksums.txt") arch := runtime.GOARCH - if arch == "arm" { + ext := ".tar.gz" + + if runtime.GOOS == "windows" { + ext = ".zip" + } + if arch == "arm" { arch += "v" + os.Getenv("GOARM") } 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) - archivePath := filepath.Join(cachedir, base+".tar.gz") + url := fmt.Sprintf("https://github.com/golangci/golangci-lint/releases/download/v%s/%s%s", version, base, ext) + archivePath := filepath.Join(cachedir, base+ext) if err := csdb.DownloadFile(url, archivePath); err != nil { log.Fatal(err) } diff --git a/internal/build/download.go b/internal/build/download.go index 0ed0b5e130..efb223b327 100644 --- a/internal/build/download.go +++ b/internal/build/download.go @@ -58,7 +58,7 @@ func (db *ChecksumDB) Verify(path string) error { } fileHash := hex.EncodeToString(h.Sum(nil)) 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 }