Skip to content

Commit 41688df

Browse files
committed
Use a pinned Go version for golangci-lint.
1 parent 92c8b91 commit 41688df

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

.pre-commit-config.yaml

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,24 @@ repos:
5050
- id: markdown-link-check
5151
exclude: ^(vendor)
5252

53-
- repo: https://github.com/golangci/golangci-lint
54-
rev: v1.60.1
53+
- repo: local
5554
hooks:
55+
- id: executable-shell
56+
name: executable-shell
57+
entry: chmod +x
58+
language: system
59+
types: [shell]
60+
5661
- id: golangci-lint
62+
name: golangci-lint
63+
language: system
64+
types: [go]
65+
require_serial: true
66+
pass_filenames: false
67+
entry: etc/golangci-lint.sh
68+
69+
- id: check-licenses
70+
name: check-licenses
71+
language: system
72+
types: [go]
73+
entry: etc/check_license.sh

etc/golangci-lint.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
set -ex
3+
4+
# Keep this in sync with go version used in static-analysis Evergreen build variant.
5+
GO_VERSION=1.22.8
6+
GOLANGCI_LINT_VERSION=1.60.1
7+
8+
# Unset the cross-compiler overrides while downloading binaries.
9+
GOOS_ORIG=${GOOS:-}
10+
export GOOS=
11+
GOARCH_ORIG=${GOARCH:-}
12+
export GOARCH=
13+
14+
go install golang.org/dl/go$GO_VERSION@latest
15+
go${GO_VERSION} download
16+
GOROOT="$(go${GO_VERSION} env GOROOT)"
17+
PATH="$GOROOT/bin:$PATH"
18+
export PATH
19+
export GOROOT
20+
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v${GOLANGCI_LINT_VERSION}
21+
22+
export GOOS=$GOOS_ORIG
23+
export GOARCH=$GOARCH_ORIG
24+
golangci-lint run --config .golangci.yml ./...

0 commit comments

Comments
 (0)