From 58d6a5643a22df7008c1690bf492e04edc237221 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Sat, 30 Aug 2025 18:52:31 +0000 Subject: [PATCH] Improve lint target to check and fix Go version mismatches - Add version checking logic to detect golangci-lint Go version compatibility - Automatically reinstall golangci-lint with correct Go version if mismatch detected - Use GOTOOLCHAIN to ensure installation with project's required Go version - Prevents future 'Go language version used to build golangci-lint is lower than targeted Go version' errors Co-Authored-By: Alec Fong --- Makefile | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8cffa63..7ea71ba 100644 --- a/Makefile +++ b/Makefile @@ -110,7 +110,17 @@ bench: lint: @echo "Running linter..." @if ! command -v $(GOLINT) > /dev/null 2>&1; then \ - $(GOINSTALL) $(ARTIFACT_GOLINT); \ + echo "golangci-lint not found. Installing..."; \ + GOTOOLCHAIN=go$(shell $(GOCMD) list -m -f '{{.GoVersion}}') $(GOINSTALL) $(ARTIFACT_GOLINT); \ + else \ + REQUIRED_GO_VERSION=$$($(GOCMD) list -m -f '{{.GoVersion}}'); \ + LINTER_GO_VERSION=$$($(GOLINT) version 2>/dev/null | grep -o 'go[0-9]\+\.[0-9]\+\.[0-9]\+' | head -1 | sed 's/go//'); \ + if [ -n "$$LINTER_GO_VERSION" ] && [ -n "$$REQUIRED_GO_VERSION" ]; then \ + if ! printf '%s\n%s\n' "$$REQUIRED_GO_VERSION" "$$LINTER_GO_VERSION" | sort -V -C 2>/dev/null; then \ + echo "golangci-lint was built with Go $$LINTER_GO_VERSION but project requires Go $$REQUIRED_GO_VERSION. Reinstalling..."; \ + GOTOOLCHAIN=go$$REQUIRED_GO_VERSION $(GOINSTALL) $(ARTIFACT_GOLINT); \ + fi; \ + fi; \ fi $(GOLINT) run ./... @@ -219,4 +229,4 @@ help: @echo " docs - Generate documentation" @echo " check - Run all checks (lint, vet, fmt-check, test)" @echo " install-tools - Install development tools" - @echo " help - Show this help message" \ No newline at end of file + @echo " help - Show this help message" \ No newline at end of file