LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

go-clean

remove Go build artifacts and cached data

TLDR

Clean build cache
$ go clean
copy
Clean test cache
$ go clean -testcache
copy
Clean module cache
$ go clean -modcache
copy
Clean all caches
$ go clean -cache -testcache -modcache
copy
Clean fuzz test cache
$ go clean -fuzzcache
copy
Dry run showing what would be removed
$ go clean -n [package]
copy
Clean verbosely showing remove commands
$ go clean -x -cache
copy

SYNOPSIS

go clean [options] [packages]

DESCRIPTION

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.

PARAMETERS

PACKAGES

Packages to clean.
-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.

CAVEATS

Module cache clean affects all projects. Test cache clean forces test reruns. May need re-download dependencies.

HISTORY

go clean is part of the Go toolchain, providing cache and artifact management.

SEE ALSO

go(1), go-build(1), go-mod(1), go-test(1)

Copied to clipboard
Kai