Skip to content

feat(go): Support golangci-lint via go tool#706

Merged
aeppling merged 1 commit intortk-ai:developfrom
shwoop:go-tool-golangci
Mar 28, 2026
Merged

feat(go): Support golangci-lint via go tool#706
aeppling merged 1 commit intortk-ai:developfrom
shwoop:go-tool-golangci

Conversation

@shwoop
Copy link
Copy Markdown

@shwoop shwoop commented Mar 18, 2026

Summary

As of go v1.24, tools such as golanci-lint can be managed via the mod file and called directly on the go binary via the tool subcommand.

When called via tools, we now apply the same logic to compact the results as in the directly called command.

Resolves #744

Test plan

  • cargo fmt --all && cargo clippy --all-targets && cargo test
  • Manual testing: rtk <command> output inspected

Manual testing

I created a simple mock golang project:

[~/repos/test]$ head go.mod
module rtk-test

go 1.26.1

tool github.com/golangci/golangci-lint/cmd/golangci-lint

require (
	4d63.com/gocheckcompilerdirectives v1.3.0 // indirect
	4d63.com/gochecknoglobals v0.2.2 // indirect
	github.com/4meepo/tagalign v1.4.2 // indirect
[~/repos/test]$ cat main.go 
package main

import "fmt"

func main() {
	i := fmt.Sprintf("hello %s", 9.0)
	fmt.Println(i)
}

golangci-lint is not impressed:

[~/repos/test]$ go tool golangci-lint run main.go 
main.go:6:7: printf: fmt.Sprintf format %s has arg 9.0 of wrong type float64 (govet)
	i := fmt.Sprintf("hello %s", 9.0)
	    ^

rtk currently (develop head) parrots the vanilla response:

[~/repos/test]$ rtk go tool golangci-lint run main.go
main.go:6:7: printf: fmt.Sprintf format %s has arg 9.0 of wrong type float64 (govet)
	i := fmt.Sprintf("hello %s", 9.0)
	    ^

Using this code, we see the truncated response:

[~/repos/test]$ ../rtk/target/debug/rtk go tool golangci-lint run main.go 
golangci-lint: 1 issues in 1 files
═══════════════════════════════════════
Top linters:
  govet (1x)

Top files:
  main.go (1 issues)
    govet (1)

In this scenario, we are not relying on the file on our path (as rtk golangci-lint does):

[~/repos/test]$ which golangci-lint
golangci-lint not found

testing with v2

Same code as above but replacing golangci-lint with v2.

[~/repos/test]$ cat go.mod | grep golangci-lint
tool github.com/golangci/golangci-lint/v2/cmd/golangci-lint
        github.com/golangci/golangci-lint/v2 v2.11.3 // indirect
[~/repos/test]$ ../rtk/target/debug/rtk go tool golangci-lint
golangci-lint: 1 issues in 1 files
═══════════════════════════════════════
Top linters:
  govet (1x)

Top files:
  main.go (1 issues)
    govet (1)
      → i := fmt.Sprintf("hello %s", 9.0)

Important: All PRs must target the develop branch (not master).
See CONTRIBUTING.md for details.

@aeppling aeppling added the enhancement New feature or request label Mar 20, 2026
@aeppling
Copy link
Copy Markdown
Contributor

Hello shwoop,

I'll first merge the candidat that resolve requested changes first ( 612 vs 722 , 597 has not been selected as a candidat for this)

Then ready to review your PR

@aeppling aeppling self-assigned this Mar 20, 2026
@aeppling
Copy link
Copy Markdown
Contributor

Blockers resolved

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 20, 2026

CLA assistant check
All committers have signed the CLA.

@shwoop shwoop force-pushed the go-tool-golangci branch from 308596c to 27e996f Compare March 20, 2026 19:21
@shwoop
Copy link
Copy Markdown
Author

shwoop commented Mar 20, 2026

Blockers resolved

I've refactored to add v2 support so ready for review.

@shwoop shwoop force-pushed the go-tool-golangci branch from 27e996f to a4d9bcd Compare March 22, 2026 09:18
@shwoop
Copy link
Copy Markdown
Author

shwoop commented Mar 22, 2026

Added missing signoff.

@aeppling
Copy link
Copy Markdown
Contributor

Hey

We are cleaning up the codebase and improving the project structure for better onboarding. As part of this effort, PR #826 reorganizes src/ from a flat layout into subfolders.

No logic changes — only file moves and import path updates.

What you need to do

Rebase your branch on develop when receiving this comment:

git fetch origin && git rebase origin/develop

Git detects renames automatically. If you get import conflicts, update the paths:

use crate::git;        // now: use crate::cmds::git::git;
use crate::tracking;   // now: use crate::core::tracking;
use crate::config;     // now: use crate::core::config;
use crate::init;       // now: use crate::hooks::init;
use crate::gain;       // now: use crate::analytics::gain;

Need help rebasing? Tag @aeppling

As of go v1.24, tools such as golanci-lint can be managed via the mod
file and called directly on the go binary via the tool subcommand.

When called via tools, we now apply the same logic to compact the
results as in the directly called command.

Signed-off-by: shwoop <monkey.mambo.al.ferguson@gmail.com>
@shwoop shwoop force-pushed the go-tool-golangci branch from e7fdc61 to 8f985a2 Compare March 27, 2026 18:53
@aeppling
Copy link
Copy Markdown
Contributor

aeppling commented Mar 28, 2026

Merged, will be available in next release.

Thanks for your contribution @shwoop !

@aeppling aeppling merged commit 8ab0f3d into rtk-ai:develop Mar 28, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants