Go Build Cache: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 5: Line 5:
The Go build cache is the filesystem storage used by the Go compiler to store source file hashes and object files produced by builds. This data allows the Go compiler to implement [[Go_Language#Incremental_Builds|incremental builds]].
The Go build cache is the filesystem storage used by the Go compiler to store source file hashes and object files produced by builds. This data allows the Go compiler to implement [[Go_Language#Incremental_Builds|incremental builds]].


On a Mac, the build cache resides under <code>/Users/<user-name>/Library/Cache/go-build</code>. The cache can be cleaned with <code>[[Go_Tool#clean|go clean]]</code>.
On a Mac, the build cache resides under <code>/Users/<user-name>/Library/Cache/go-build</code>, where <code>/Users/<user-name>/Library/Cache</code> is the standard user cache directory for MacOS. The location is also specified by the <code>GOCACHE</code> environment variable, which can be printed with:


<font size=-1>
go env GOCACHE
</font>


The cache can be cleaned with <code>[[Go_Tool#clean|go clean]]</code>.
<font color=darkkhaki>What is the relationship with the [[Go_Modules#Module_Cache|module cache]]?
<font color=darkkhaki>What is the relationship with the [[Go_Modules#Module_Cache|module cache]]?



Revision as of 23:07, 15 September 2023

Internal

Overview

The Go build cache is the filesystem storage used by the Go compiler to store source file hashes and object files produced by builds. This data allows the Go compiler to implement incremental builds.

On a Mac, the build cache resides under /Users/<user-name>/Library/Cache/go-build, where /Users/<user-name>/Library/Cache is the standard user cache directory for MacOS. The location is also specified by the GOCACHE environment variable, which can be printed with:

go env GOCACHE


The cache can be cleaned with go clean. What is the relationship with the module cache?

Fuzz Cache

Can be cleaned with go clean -fuzzcache.