Tiny (without dependencies) go run package@version
alternative that pre-installs binaries into (project) local directory. This eliminates waiting of tools building on every go generate
call (gotools itself builds relatively fast).
Why not use «tools.go» approach which tracks apps versions in go.mod? Because in that way tools dependencies becomes project dependencies and affects project's dependency graph and vice versa: your project dependencies affects tools dependencies, and even more: tools affects each other dependencies. This is wrong, because and your project and each tool should have their own dependencies isolated from others.
When gotools invoked it searches for go.tools
file in current working directory or in one of it parents. It makes sense to store go.tools
in the same directory as go.mod
and go.sum
. go.tools
content example:
github.com/ogen-go/ogen/cmd/[email protected]
github.com/sqlc-dev/sqlc/cmd/[email protected]
Use these tools with gotools
like this:
//go:generate go run github.com/shagohead/[email protected] ogen -target=client -package=client -clean openapi.yaml
//go:generate go run github.com/shagohead/[email protected] sqlc generate