How to use the new "tool" directive
Go 1.24 new "tool" directive.
The Go build system is known for its efficiency and continuous improvement. Go 1.24 introduces a significant enhancement with the “tool” directive, addressing how Go-based dev tools are managed.
Previously, managing tools like linters (golangci-lint), code generators (mockery, oapi-codegen), or other build utilities often involved manual installation steps (using “go install” or some package manager) outside the project's dependency management, leading to potential version inconsistencies across development environments and CI systems.
I’ve seen it many times when two developers generate different code by using the same command, only because the versions of these tools are different. There are workarounds to “fix“ the versions in fake “tools.go” file, but it’s not enough and felt dirty.
But not anymore! Go 1.24 addresses these challenges directly with the “tool” directive.



