I'm looking for a way to have staticcheck create annotations on PRs, something like this:

Running staticcheck in golangci-lint produces such annotations, but the standalone version doesn't.
I created a minimal working example in
The GitHub Actions workflow is the following:
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: "1.15.x"
- run: go get honnef.co/go/tools/cmd/staticcheck
- run: staticcheck ./...
It does find the problem in my code (if you look at the linter output), but the PR is not annotated: https://github.com/marten-seemann/linter-test/pull/2/files
It works for me when using the following action instead:
on: [push, pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: "1.15.x"
- run: go get honnef.co/go/tools/cmd/staticcheck
- run: $(go env GOPATH)/bin/staticcheck ./...
The only relevant difference is that it's using setup-go@v1 instead of v2. (It also has to call the staticcheck binary directly, as setup-go@v1 didn't add $GOPATH/bin to the PATH, but that should not be important.)
So, to me, this looks like a regression in the setup-go action. Looking at the difference between v1 and v2, the pattern they use to match output has changed from ^([^:]*: )?((.:)?[^:]*):(\\d+)(:(\\d+))?: (.*)$ to ^\\s*(\\.{0,2}[\\/\\\\].+\\.go):(?:(\\d+):(\\d+):)? (.*) (\ are escaped because the expressions are stored in JSON strings)
And indeed, the new pattern doesn't match our output. I'll try and file an issue with the setup-go people.
I have sent https://github.com/actions/setup-go/pull/98
Wow, very nice digging!
Lacking any progress whatsoever in actions/setup-go, I now recommend using https://github.com/WillAbides/setup-go-faster instead, which is faster and has sensible problem matchers.
I am going to close this. Upstream is being upstream, and setup-go-faster is a better alternative that works correctly.
We'll mention it when we publish our article on running Staticcheck in CI.