LinuxCommandLibrary

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 specific package
$ go clean [package]
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
Clean build cache.
-testcache
Clean test cache.
-modcache
Clean module cache.
-i
Remove installed archive.
-n
Dry run.
--help
Display help information.

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)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community