Open onattech opened 1 year ago
Interesting question!
One option is something like this: https://play-with-go.dev/tools-as-dependencies_go119_en/. You can include it as an import in a project, but I guess that requires that someone run using go run gotest.tools/gotestsum
, instead of simply gotestsum
.
If you use a Makefile or some other tool for project tasks, you could include go install gotest.tools/gotestsum@latest
to get it installed.
A third option, which is pretty unconventional, is something like #151, where you run go run ./test
instead of go test
, and that runs the tests with gotestsum
.
Thank you for your reply. It turns out I am familiar with the first option. Gqlgen for graphql uses it. I'll probably go with the second option since there is a Makefile to install other dependencies.
I learned about another option which should work like "auto install". You can run go tools like this without then being in the go.mod
file:
go run gotest.tools/gotestsum@latest [gotestsum flags]
If the module already exists in $GOPATH/pkg/mod/...
it will run it. It the source isn't available locally it will download the source, compile, and run.
gotestsum
has very few dependencies, so it doesn't take long to download and compile on the fly like this.
Hi, How can I get
gotestsum
to be a dependency in a project or get it auto installed. I don't want to tell the user to manually install it. Thank you