fix(builtins): use workspace_indicator for Go package-level analysis tools#803
fix(builtins): use workspace_indicator for Go package-level analysis tools#803
Conversation
…tools
Go tools that use go/packages internally (go vet, golangci-lint, gosec,
govulncheck, staticcheck, revive, errcheck) fail when {{ files }} expands
to paths spanning multiple packages, because go list requires all named
files to be in one directory. Switch these builtins to use
workspace_indicator = "go.mod" with ./... instead of {{ files }}.
File-level formatters (gofmt, gofumpt, goimports, golines) are unchanged
as they operate on individual files without needing package context.
Fixes #802
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Greptile SummaryFixes the "named files must all be in one directory" error that occurs when Go package-level analysis tools receive files spanning multiple packages. Seven Go analysis builtins are switched from passing
Confidence Score: 5/5Safe to merge — all 7 builtins receive the same correct workspace-scoped fix with no logic errors or regressions No P0 or P1 issues found. The root cause (Go toolchain rejecting multi-directory file lists) is well-understood and the fix is the canonical approach used across Go tooling. The only remaining gap is that 6 of 7 changed builtins lack Pkl-level tests, but this was already flagged in a prior review thread and does not affect the correctness of the changes. No files require special attention; all changes are consistent and well-scoped Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Go .go file staged] --> B{glob matches?}
B -- No --> C[Step skipped]
B -- Yes --> D{workspace_indicator
go.mod found?}
D -- No --> C
D -- Yes --> E[Resolve workspace dir]
E --> F[cd workspace]
F --> G[tool ./...]
G --> H{Exit code}
H -- 0 --> I[Step passes]
H -- non-0 --> J[Step fails / reported]
Reviews (3): Last reviewed commit: "fix(builtins): add go tool stub for go_v..." | Re-trigger Greptile |
There was a problem hiding this comment.
Code Review
This pull request updates several Go-related builtin analysis tools to use workspace-based execution (cd {{workspace}} && ... ./...) instead of individual file lists, enabling support for multi-package projects and monorepos. A new test suite was added to verify these changes. The review feedback consistently recommends enclosing the {{workspace}} variable in double quotes across all modified files to ensure the commands remain robust when workspace paths contain spaces.
| glob = "**/*.go" | ||
| check = "errcheck {{ files }}" | ||
| workspace_indicator = "go.mod" | ||
| check = "cd {{workspace}} && errcheck ./..." |
There was a problem hiding this comment.
The {{workspace}} variable should be enclosed in double quotes to ensure the command remains robust if the workspace path contains spaces. Since this command is executed via a shell, unquoted paths with spaces will cause the cd command to fail or behave unexpectedly.
check = "cd \"{{workspace}}\" && errcheck ./..."
| glob = "**/*.go" | ||
| check = "gosec {{ files }}" | ||
| workspace_indicator = "go.mod" | ||
| check = "cd {{workspace}} && gosec ./..." |
| glob = "**/*.go" | ||
| check = "go vet {{ files }}" | ||
| workspace_indicator = "go.mod" | ||
| check = "cd {{workspace}} && go vet ./..." |
| glob = "**/*.go" | ||
| check = "govulncheck {{ files }}" | ||
| workspace_indicator = "go.mod" | ||
| check = "cd {{workspace}} && govulncheck ./..." |
| check = "cd {{workspace}} && golangci-lint run --fix=false ./..." | ||
| fix = "cd {{workspace}} && golangci-lint run --fix ./..." |
There was a problem hiding this comment.
| glob = "**/*.go" | ||
| check = "revive {{ files }}" | ||
| workspace_indicator = "go.mod" | ||
| check = "cd {{workspace}} && revive ./..." |
| glob = "**/*.go" | ||
| check = "staticcheck {{ files }}" | ||
| workspace_indicator = "go.mod" | ||
| check = "cd {{workspace}} && staticcheck ./..." |
Replace bats integration test with proper pkl-level tests for go_vet that exercise the workspace_indicator + ./... pattern with real Go code. Add mise tool stubs for golangci-lint, staticcheck, revive, and gosec. Document builtin testing patterns in CLAUDE.md. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The go_vet pkl tests need the `go` binary, which isn't available in all CI environments. Add a mise tool-stub for `go` so the builtins test harness can auto-install it. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This MR contains the following updates: | Package | Update | Change | |---|---|---| | [hk](https://github.com/jdx/hk) | minor | `1.40.0` → `1.41.0` | MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot). **Proposed changes to behavior should be submitted there as MRs.** --- ### Release Notes <details> <summary>jdx/hk (hk)</summary> ### [`v1.41.0`](https://github.com/jdx/hk/blob/HEAD/CHANGELOG.md#1410---2026-04-05) [Compare Source](jdx/hk@v1.40.0...v1.41.0) ##### 🚀 Features - **(hook)** support per-worktree hooks via extensions.worktreeConfig by [@​nkakouros](https://github.com/nkakouros) in [#​789](jdx/hk#789) ##### 🐛 Bug Fixes - **(builtins)** use workspace\_indicator for Go package-level analysis tools by [@​jdx](https://github.com/jdx) in [#​803](jdx/hk#803) - **(config)** use XDG\_CONFIG\_HOME for config path instead of dirs::config\_dir() by [@​fukuchancat](https://github.com/fukuchancat) in [#​801](jdx/hk#801) ##### 📦️ Dependency Updates - update anthropics/claude-code-action digest to [`0432df8`](jdx/hk@0432df8) by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​791](jdx/hk#791) - update rust crate indexmap to v2.13.1 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​792](jdx/hk#792) - update actions/configure-pages action to v6 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​795](jdx/hk#795) - update rust crate strum to 0.28 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​794](jdx/hk#794) - update actions/deploy-pages action to v5 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​796](jdx/hk#796) - update dependency globals to v17 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​797](jdx/hk#797) - update github artifact actions (major) by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​798](jdx/hk#798) - update jdx/mise-action action to v4 by [@​renovate\[bot\]](https://github.com/renovate\[bot]) in [#​799](jdx/hk#799) ##### New Contributors - [@​fukuchancat](https://github.com/fukuchancat) made their first contribution in [#​801](jdx/hk#801) </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this MR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box --- This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xMDQuMSIsInVwZGF0ZWRJblZlciI6IjQzLjEwNC4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiLCJhdXRvbWF0aW9uOmJvdC1hdXRob3JlZCIsImRlcGVuZGVuY3ktdHlwZTo6bWlub3IiXX0=-->
Summary
go_vet,golangci_lint,go_sec,go_vuln_check,staticcheck,revive,err_check) from{{ files }}toworkspace_indicator = "go.mod"with./...go/packagesfail with "named files must all be in one directory" when files span multiple packages — this is a Go toolchain constraint, not a bug in any lintergo_fmt,go_fumpt,go_imports,go_lines) are unchanged as they don't need package contextFixes #802
Test plan
🤖 Generated with Claude Code
Note
Medium Risk
Changes how several Go builtins invoke analyzers by switching from file-list execution to module-wide
./...runs, which can alter coverage/performance and step results in monorepos. Adds new builtin test/tool-stub infrastructure, but the changes are contained to builtin definitions and test scaffolding.Overview
Updates Go package-level builtin steps (
go_vet,golangci_lint,go_sec,go_vuln_check,staticcheck,revive,err_check) to run from the detected Go module root viaworkspace_indicator = "go.mod"and execute against./...instead of passing{{files}}.Adds pkl-level tests for
go_vet(including a multi-package case) and introducesmisetool stubs undertest/builtin_tool_stubs/for Go and several Go linters/scanners. Documentation inCLAUDE.mdis expanded with guidance on writing/running builtin tests and using tool stubs.Reviewed by Cursor Bugbot for commit aa8c16b. Bugbot is set up for automated code reviews on this repo. Configure here.