Files
trufflehog/scripts/lint.sh
renovate[bot]Cursorrenovate[bot] <29139614+renovate[bot]@users.noreply.github.com>Bryan Beverly
a904c69a58 Update github-actions (#5197)
* Update github-actions

* Match scripts/lint.sh golangci-lint version to CI workflow

The workflow moved to v2.13.1 while local linting stayed on v2.12.2. go1.27
support landed in golangci-lint v2.13.0, so with this PR bumping CI to Go 1.27
a developer on that toolchain would see `make lint` fail outright.

Co-authored-by: Cursor <[email protected]>

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Bryan Beverly <[email protected]>
Co-authored-by: Cursor <[email protected]>
2026-08-25 09:17:27 -07:00

33 lines
1.3 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# NOTE: Version and args must match .github/workflows/lint.yml
GOLANGCI_LINT_VERSION="v2.13.1"
LINT_ARGS="--enable bodyclose,copyloopvar,misspell --timeout 10m"
GOBIN="$(go env GOPATH)/bin"
GOLANGCI_LINT="${GOBIN}/golangci-lint"
# Extract and compare the exact version to avoid substring matches (e.g. 2.11.4 matching 2.11.40).
check_version() {
local bin="$1"
local installed
installed=$("${bin}" version 2>&1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1)
[[ "${installed}" == "${GOLANGCI_LINT_VERSION#v}" ]]
}
# Check PATH first, then fall back to GOPATH/bin, otherwise install.
if command -v golangci-lint &>/dev/null && check_version "$(command -v golangci-lint)"; then
GOLANGCI_LINT="$(command -v golangci-lint)"
echo "golangci-lint ${GOLANGCI_LINT_VERSION} found at ${GOLANGCI_LINT}"
elif [[ -x "${GOLANGCI_LINT}" ]] && check_version "${GOLANGCI_LINT}"; then
echo "golangci-lint ${GOLANGCI_LINT_VERSION} found at ${GOLANGCI_LINT}"
else
echo "Installing golangci-lint ${GOLANGCI_LINT_VERSION}..."
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b "${GOBIN}" "${GOLANGCI_LINT_VERSION}"
fi
# shellcheck disable=SC2086
"${GOLANGCI_LINT}" run ${LINT_ARGS}