Excessive build cache size?

I’m new to Go but have 40 years of programming experience and more than 20 languages.

I have been exploring Go using a small project so the workspace only has about 18 files in 9 packages.
I have only ever used the ‘go test’ command. Since I’m changing most packages, doing an install seems like a waste of time.

I have been using a PC with limited disk space as it is only used to explore new stuff and after a few days of working with Go I ran out of disk space.

The culprit was the go-build directory which was many MB in size, but unfortunately I didn’t record the actual size. A bit of searching found the ‘go clean -cache’ command.

After 3 days of playing around the cache was 21.8 MB with a 500KB log file.

After another clean, the cache reached 12.3 MB in one day, again with a 500 KB log file.
Most of the entries are unusable since they don’t match any package source.

I have been unable to find any info on how the cache is designed to work, but it appears that it just keeps on getting bigger until you manually clean it. At which point it removes all entries. I would expect it to keep the latest entry for a package.

Subjectively, I felt that the elapsed time for my test runs varied noticeably.
I found it was much easier to simply turn off the cache.

I recently installed Go1.11 and was somewhat disturbed to see that 1.12 will require the use of the cache.

I hope I am missing something about how you are meant to work with the cache, but having to manually clean it to keep the size to a reasonable limit is a bit of a problem.

Since a clean removes all cache entries it seems to defeat the purpose of a cache.


I guess it is useful if you do several go run or go build in a row. Then it don’t have to build everything from scratch and instead use previously build things from the cache.

With kind regards, Johan

I’ve been programming daily in Go since upgrading to version 1.11. Since you brought this up, I checked my Go build cache and it is only about 5 MB. Maybe it’s because I’ve been mostly working on just one project. If it were 100 MB, it would still be too small to be a significant problem. At the moment, my ~/.cache directory is holding 1 GB. I just clean it out before doing backups. No worries.

I respectfully submit that if a cache of about 20 MB is a problem for you, then you just need to upgrade your hardware.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.