Skip to content

Commit a134f39

Browse files
committed
improve fetching of golangci-lint
1 parent 001e0b7 commit a134f39

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

hack/check-everything.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,18 @@ function is_installed {
7070
return 1
7171
}
7272

73+
function golangci_lint_has_version {
74+
# Trim "v" from version prefix since golangci-lint --version
75+
# sometimes does not include it, depending on how it's built
76+
golangci-lint --version | grep --quiet --fixed-strings "${1#"v"}"
77+
}
78+
7379
function fetch_go_tools {
74-
header_text "Checking for gometalinter.v2"
75-
if ! is_installed golangci-lint; then
80+
header_text "Checking for golangci-lint"
81+
local golangci_lint_version="v1.21.0"
82+
if ! is_installed golangci-lint || ! golangci_lint_has_version "${golangci_lint_version}"; then
7683
header_text "Installing golangci-lint"
77-
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin v1.21.0
84+
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin "${golangci_lint_version}"
7885
fi
7986
}
8087

0 commit comments

Comments
 (0)