Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make lintcmd usable from a library, without it calling os.Exit() #1597

Closed
wants to merge 1 commit into from

Conversation

sybrenstuvel
Copy link
Contributor

This PR splits most of func (cmd *Command) Run() off into func (cmd *Command) Execute() int. My goal is to be able to run staticcheck from a Go program without it calling os.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.

This PR splits most of `func (cmd *Command) Run()` off into `func (cmd
*Command) Execute() int`. My goal is to be able to run staticcheck from
a Go program without it calling `os.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][m] to
build my tool [Skyfill][s]. 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 much 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.

[m]: https://magefile.org/
[s]: https://stuvel.eu/software/skyfill/
@dominikh dominikh closed this in 9f4b51e Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant