Linux command
go-clean 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Clean build cache
go clean
Clean test cache
go clean -testcache
Clean module cache
go clean -modcache
Clean all caches
go clean -cache -testcache -modcache
Clean fuzz test cache
go clean -fuzzcache
Dry run showing what would be removed
go clean -n [package]
Clean verbosely showing remove commands
go clean -x -cache
说明
go clean removes object files and cached data. It cleans build artifacts, test results, and downloaded modules to free disk space or force rebuilding. The command can target specific caches or packages. Cleaning the module cache removes all downloaded dependencies, requiring re-download on next build.
参数
- -cache
- Remove the entire build cache.
- -testcache
- Expire all test results in the build cache.
- -modcache
- Remove the entire module download cache.
- -fuzzcache
- Remove files stored in the build cache for fuzz testing.
- -i
- Remove the corresponding installed archive or binary.
- -r
- Apply recursively to all dependencies of the named packages.
- -n
- Print the remove commands that would be executed, but do not run them.
- -x
- Print remove commands as they are executed.
FAQ
What is the go-clean command used for?
go clean removes object files and cached data. It cleans build artifacts, test results, and downloaded modules to free disk space or force rebuilding. The command can target specific caches or packages. Cleaning the module cache removes all downloaded dependencies, requiring re-download on next build.
How do I run a basic go-clean example?
Run `go clean` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -cache do in go-clean?
Remove the entire build cache.