Make lintcmd usable from a library, without it calling os.Exit() #1597
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.
This PR splits most of
func (cmd *Command) Run()
off intofunc (cmd *Command) Execute() int
. My goal is to be able to run staticcheck from a Go program without it callingos.Exit()
.Some background: for my Go projects I'm trying to lower the barrier of entry for developers as much as possible. I'm using Magefile to build my tool Skyfill. Magefile is a build tool that is written in Go, and thus can be run with just
go run mage.go
without manually installing anything first (except Go itself). As the build script is written in Go as well, I can call tools like staticcheck, govulncheck, etc. directly from go, instead of getting them installed on $PATH first.This PR makes it nicer to integrate staticcheck in my build chain; because it doesn't unconditionally call
os.Exit()
any more, it means that I can use it concurrently with other tools / build steps.