Go build touches ~/.cache which is undesirable.
How can I change the location of this directory?
The cache defaults to the operating system-defined user cache directory but can be moved by setting $GOCACHE.
Source: article from rsc
From the official documentation :
Build and test caching
The go command caches build outputs for reuse in future builds. The default location for cache data is a subdirectory named go-build in the standard user cache directory for the current operating system. Setting the GOCACHE environment variable overrides this default, and running 'go env GOCACHE' prints the current cache directory.
Note that the aforementioned go env GOCACHE
command can be used to make sure that GOCACHE
points to a desirable location before eg: building with go build
. Example:
$ go env GOCACHE
/home/user/.cache/go-build
$ GOCACHE=/foo/bar
$ export GOCACHE
$ go env GOCACHE
/foo/bar
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.