Skip to content

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

Open
shwoop wants to merge 1 commit intortk-ai:developfrom
shwoop:go-tool-golangci
Open

feat(go): Support golangci-lint via go tool#706
shwoop wants to merge 1 commit intortk-ai:developfrom
shwoop:go-tool-golangci

Conversation

@shwoop
Copy link

@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
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
Contributor

Blockers resolved

@CLAassistant
Copy link

CLAassistant commented Mar 20, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.
@shwoop shwoop force-pushed the go-tool-golangci branch from 308596c to 27e996f Compare March 20, 2026 19:21
@shwoop
Copy link
Author

shwoop commented Mar 20, 2026

Blockers resolved

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

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.

3 participants