Open rittneje opened 1 month ago
Related Issues and Documentation
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
CC @matloob
I don't know if this justifies its own environment variable (that would show up in go env
, etc.) but maybe we can make it an undocumented #
godebug setting?
@matloob If you mean something we can set via the GODEBUG
environment variable, that would also be acceptable. We just need something we can easily configure globally in the base image.
Yes. That is what I mean.
Proposal Details
We have our own docker image containing our Go toolchain. As an optimization, we also pre-compile the standard library (
go build std
) so that it is in the gocache.Evidently, the various Go tools will trim the cache upon exit. In particular, they will delete any files in the cache that have not been modified in the last five days. While this may be reasonable for a cache on someone's host machine, it does not make sense for a short-lived container using a cache from its image, since the mtimes will all reflect when the image was built. At best, it trimming the cache is pointless because the container will be destroyed shortly, and at worst is actively counterproductive as those cached files may be used by subsequent commands.
Please add an environment variable to disable trimming the gocache upon command exit. The specific name is immaterial, but something like
GOCACHE_AUTO_TRIM=0
would be fine.