feat(go): general go tool support with golangci-lint filtering#2114
Open
apowis wants to merge 7 commits into
Open
feat(go): general go tool support with golangci-lint filtering#2114apowis wants to merge 7 commits into
apowis wants to merge 7 commits into
Conversation
Next Release
…master--components--rtk chore(master): release 0.41.0
Next Release
…master--components--rtk chore(master): release 0.42.0
Fixes two bugs in the original go tool golangci-lint implementation (commit 8f985a2) and extends support to all go tool invocations. Bug 1 — double 'run' in command args: rtk go tool golangci-lint run ./... was producing 'go tool golangci-lint run --output.json.path stdout run ./...' because run_go_tool_golangci_lint always prepended 'run' before appending all args (which already included 'run'). Fix: extract build_go_tool_golangci_args() helper that strips a leading 'run' before injecting the JSON flag. Both calling forms now work correctly: rtk go tool golangci-lint run ./... (explicit run) rtk go tool golangci-lint ./... (no run prefix) Bug 2 — rewrite rule too narrow: The registry pattern only matched go tool golangci-lint, so 'go tool staticcheck ./...' and any other managed tool was never rewritten to 'rtk go tool ...' by the Claude Code hook. Fix: drop the GoTool enum in favour of match_go_tool() returning the tool name as a String, matching any 'go tool <name>'. Unknown tools are routed through a new run_go_tool_passthrough() that executes transparently and records usage in the tracking DB so they appear in 'rtk gain --history'. The rewrite pattern is broadened to '^go\s+(test|build|vet|tool\s+\S+)'. Closes rtk-ai#744
Contributor
|
Automatic message from CI checks : It seems like this branch is targeting the wrong branch, any contribution should target develop branch. See CONTRIBUTING.md for details. |
|
|
Contributor
Author
|
@aeppling - let me know if I have done everything correctly for contributing here? I did a previous PR on golangci-lint here but I remembered to use the correct base of |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #744
Summary
Fixes two bugs in the original implementation (commit 8f985a2) and extends support to all
go toolinvocations.Bug 1 — double
runin command argsrtk go tool golangci-lint run ./...was producing:because
run_go_tool_golangci_lintalways prependedrunbefore appending all args (which already includedrun).Fix: Extract
build_go_tool_golangci_args()helper that strips a leadingrunbefore injecting the JSON flag. Both calling forms now work:rtk go tool golangci-lint run ./...(explicit run)rtk go tool golangci-lint ./...(no run prefix)Bug 2 — rewrite rule and runtime dispatch too narrow
The original implementation only handled
go tool golangci-lint— any other managed tool (go tool staticcheck,go tool pprof, etc.) was never rewritten by the hook and never tracked.Fix:
GoToolenum;match_go_tool()now returns the tool name as aStringand matches anygo tool <name>run_go_tool_passthrough()that executes transparently and records usage in the tracking DB (visible inrtk gain --history)^go\s+(test|build|vet)to^go\s+(test|build|vet|tool\s+\S+)Behaviour after this change
go tool golangci-lint run ./...go tool golangci-lint ./...go tool staticcheck ./...go tool pprof cpu.profgo tool <x>Test plan
match_go_tool(now accepts any tool name) andbuild_go_tool_golangci_args(no double-run)go tool