GO-CLEAN(1)

✨ NAME ✨

go-clean β€” remove object files and cached files πŸ§ΉπŸ’–

okay bestie, welcome to the go-clean page from the Go programming tools and commands manual. it's giving "spring cleaning but for your build artifacts" and honestly? obsessed. let's get into it 🫢


🌸 SYNOPSIS 🌸

go clean [-i] [-r] [-cache] [-testcache] [-modcache] [-fuzzcache] [build
flags] [packages]

πŸŽ€ DESCRIPTION πŸŽ€

clean removes object files from package source directories. lowkey important thing to know: the go command builds most objects in a temporary directory, so go clean is mainly concerned with object files left by other tools or by manual invocations of go build. so it's less "cleaning up after go" and more "cleaning up after everything else" πŸ’…

If a package argument is given, or the -i or -r flag is set, clean removes the following files from each of the source directories corresponding to the import paths. not me giving you the full list, but here it is, no skips:

  • _obj/ β€” old object directory, left from Makefiles
  • _test/ β€” old test directory, left from Makefiles
  • _testmain.go β€” old gotest file, left from Makefiles
  • test.out β€” old test log, left from Makefiles
  • build.out β€” old test log, left from Makefiles
  • *.[568ao] β€” object files, left from Makefiles
  • DIR(.exe) β€” from go build
  • DIR.test(.exe) β€” from go test -c
  • MAINFILE(.exe) β€” from go build MAINFILE.go
  • *.so β€” from SWIG

In the list, DIR represents the final path element of the directory, and MAINFILE is the base name of any Go source file in the directory that is not included when building the package. iykyk πŸ¦‹


πŸ‘‘ OPTIONS πŸ‘‘

  • -i β€” causes clean to remove the corresponding installed archive or binary (what go install would create).
  • -n β€” causes clean to print the remove commands it would execute, but not run them. window shopping but for deletion πŸ›οΈ
  • -r β€” causes clean to be applied recursively to all the dependencies of the packages named by the import paths.
  • -x β€” causes clean to print remove commands as it executes them.
  • -cache β€” causes clean to remove the entire go build cache.
  • -testcache β€” causes clean to expire all test results in the go build cache.
  • -modcache β€” causes clean to remove the entire module download cache, including unpacked source code of versioned dependencies. yes including the unpacked source, bestie, read that twice 😭
  • -fuzzcache β€” causes clean to remove files stored in the Go build cache for fuzz testing. quick heads up: the fuzzing engine caches files that expand code coverage, so removing them may make fuzzing less effective until new inputs are found that provide the same coverage. also these files are distinct from those stored in testdata directory β€” clean does not remove those files. πŸ›

For more about build flags, see go help build.

For more about specifying packages, see go help packages.


🫢 AUTHOR 🫢

This manual page was created using help2man and afterwards updating the output. It is maintained by the Debian Go Compiler Team <team+go-compiler@tracker.debian.org> for the Debian project (and may be used by others).


okay that's the whole page, you ate that πŸ“ this is the go-clean page, part of Go 1.27, dated August 2026, sitting in the Go programming tools and commands manual β€” go forth and delete responsibly, mwah πŸ’‹πŸŒˆ

πŸ“¦ where this page comes from