Skip to content

BE-730 | golangci-lint use toolchain of current go.mod version #650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 5, 2025

Conversation

deividaspetraitis
Copy link
Member

@deividaspetraitis deividaspetraitis commented May 5, 2025

Older versions of golangci-lint has some memory leaks when running with newer Go versions leading consuming all available RAM and crashing, context.

This PR forces to use same Go version for golangci-lint as in the module ( go.mod ).

Summary by CodeRabbit

  • Chores
    • Updated internal build process to use a specific Go toolchain version when running code linting tasks. No changes to user-facing features.

@deividaspetraitis deividaspetraitis self-assigned this May 5, 2025
Copy link
Contributor

coderabbitai bot commented May 5, 2025

Walkthrough

The Makefile was updated to introduce a new variable, GOTOOLCHAIN, which is constructed by appending the Go version (extracted from go.mod) to the string "go". The lint target now uses this variable to ensure that golangci-lint runs with the designated Go toolchain version. No other targets or commands were changed.

Changes

File(s) Change Summary
Makefile Added GOTOOLCHAIN variable and updated the lint target to use it with golangci-lint

Suggested reviewers

  • p0mvn

Poem

A rabbit hopped by with a Makefile in paw,
Tweaked the toolchain—oh, what it saw!
Now linting’s precise, with version in tow,
Go and the linter in perfect flow.
🐇✨


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
Makefile (2)

11-12: Validate and robustly extract Go version

The current extraction using cat and a broad regex may match unintended lines and incurs an extra subshell. Consider anchoring the pattern and avoiding cat:

-GO_VERSION := $(shell cat go.mod | grep -E 'go [0-9].[0-9]+' | cut -d ' ' -f 2)
+GO_VERSION := $(shell grep -E -m1 '^go [0-9]+\.[0-9]+' go.mod | cut -d ' ' -f 2)

Also ensure that any environment (CI or local) where this Makefile runs has the corresponding go$(GO_VERSION) binary installed, since it's referenced later in the lint target.


60-62: Verify golangci-lint support for GOTOOLCHAIN env var

This change relies on golangci-lint recognizing the GOTOOLCHAIN environment variable (per golangci/golangci-lint#5695). Please confirm that your CI and dev environments use a compatible golangci-lint version; otherwise, the toolchain override will be ignored.

Optionally, to fail early if the specified Go binary is missing, you could add:

lint:
	@echo "--> Running linter"
+	@if ! command -v $(GOTOOLCHAIN) >/dev/null 2>&1; then \
+	  echo "Error: Go toolchain '$(GOTOOLCHAIN)' not found"; \
+	  exit 1; \
+	fi
	GOTOOLCHAIN=$(GOTOOLCHAIN) golangci-lint run --timeout=10m
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 63ec80f and 238dd63.

📒 Files selected for processing (1)
  • Makefile (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: Run linter
  • GitHub Check: build
  • GitHub Check: Summary

Copy link

sonarqubecloud bot commented May 5, 2025

@deividaspetraitis deividaspetraitis merged commit df80f2c into v28.x May 5, 2025
9 checks passed
@deividaspetraitis deividaspetraitis deleted the BE-730 branch May 5, 2025 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant