From 649c9a083a0596087ccb9b5e155b94dccea03223 Mon Sep 17 00:00:00 2001 From: Alberto Cavalcante <54247214+albertocavalcante@users.noreply.github.com> Date: Tue, 22 Apr 2025 19:59:18 -0700 Subject: [PATCH] chore(check): use golangci-lint from GOPATH/bin as first option --- scripts/check.sh | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/scripts/check.sh b/scripts/check.sh index 069947ff..4f9b04fa 100755 --- a/scripts/check.sh +++ b/scripts/check.sh @@ -3,10 +3,23 @@ set -o errexit set -o pipefail -if command -v golangci-lint &> /dev/null -then - golangci-lint run --verbose +# TODO: Check if the found golangci-lint version matches the expected version (e.g., v1.62.0), especially if falling back to PATH version. + +GOPATH_LINT="$(go env GOPATH)/bin/golangci-lint" +BIN_LINT="./bin/golangci-lint" +LINT_CMD="" + +if [ -f "$GOPATH_LINT" ]; then + LINT_CMD="$GOPATH_LINT" +elif [ -f "$BIN_LINT" ]; then + LINT_CMD="$BIN_LINT" +elif command -v golangci-lint &> /dev/null; then + # Using PATH version, ensure compatibility (see TODO) + LINT_CMD="golangci-lint" else - ./bin/golangci-lint run --verbose + echo "Error: golangci-lint not found in $GOPATH/bin, ./bin, or PATH." + echo "Please run scripts/devtools.sh or ensure golangci-lint is installed correctly." + exit 1 fi +"$LINT_CMD" run --verbose