Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

run go vet and staticcheck in go-check #22

Merged
merged 1 commit into from Mar 8, 2021
Merged

Conversation

marten-seemann
Copy link
Contributor

Fixes #6.

Run go vet and staticcheck without any involvement of golangci-lint. golangci-lint is a quite complicated beast, and we're probably better off just running the tools ourselves.

See marten-seemann-test/target#33 for a demo of this workflow.

This has been blocked by the problems with staticcheck for way too long. I'm now using a regex to fix the output, such that GitHub Annotations will pick up the path. All we need to do is transform cmd/main.go:5:6: func build is unused (U1000) to ./cmd/main.go:5:6: func build is unused (U1000).

workflow-templates/go-check.yml Outdated Show resolved Hide resolved
if: ${{ success() || failure() }}
run: |
set -o pipefail
staticcheck ./... | sed -e "s/\(.*\)\.go/.\/\1.go/g"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps document the sed with a TODO comment pointing at the setup-go issue.

Also, I think it would be clearer to use single quotes for regexps, so that shell escaping doesn't play a part. You can also use a different separator to not have to escape the slash:

sed -e 's@\(.*\)\.go@./\1.go/g'

I also wonder if you want [^ ]+\.go for filenames, as that might have fewer false positives like foo bar.go.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried [^ ]+\.go, but sed doesn't like it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

run staticcheck
2 participants