Go 1.24 introduces new functionality for managing developer tooling dependencies. Tooling includes static code analysis tools like staticcheck, vulnerability scanning tools like govulncheck, and live-reloading tools like air. Historically, managing these dependencies was tricky using tools.go file or go run pattern. With Go 1.24, there's a better way.
Key Commands and Features
go get -tool import_path@versionto add tools to module.go toolcommand to run tools from command line, in makefiles, or withgo:generate.go list toolto list added tools.go mod verifyto check tool code in module cache.go mod vendorto include tooling code invendorfolder.go get -tool import_path@versionto upgrade or downgrade tools.go get -tool @noneto remove tools.- Use a separate
modfilefor tool dependencies with-modfileflag.
Example
- Scaffold a simple module and add application code.
- Use
go get -toolto add tools likestringer,govulncheck, andstaticcheck. - Run tools using different methods like from command line, makefile, or
go:generate. - See how vendoring tools works and its limitations.
Risks and Considerations
- If tools share dependencies with application code, it may cause version conflicts and break application code.
- Using a separate
modfilefor tools can reduce this risk.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用。你还可以使用@来通知其他用户。