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@version
to add tools to module.go tool
command to run tools from command line, in makefiles, or withgo:generate
.go list tool
to list added tools.go mod verify
to check tool code in module cache.go mod vendor
to include tooling code invendor
folder.go get -tool import_path@version
to upgrade or downgrade tools.go get -tool @none
to remove tools.- Use a separate
modfile
for tool dependencies with-modfile
flag.
Example
- Scaffold a simple module and add application code.
- Use
go get -tool
to 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
modfile
for tools can reduce this risk.
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。