Documentation
¶
Overview ¶
Package gocache trims the Go build cache to the working set of one CI run, so the cache CI saves stays the size of what a build actually uses instead of accreting a layer of stale compile output with every save.
It relies on how cmd/go maintains the cache (src/cmd/go/internal/cache/cache.go): every use of an entry refreshes its mtime, but at most once per mtimeInterval (one hour). So after a run, every entry that run read or wrote has an mtime no earlier than an hour before the run started; anything older went unused. Go's own trim deletes entries unused for five days, which never fires in a cache CI restores and re-saves daily.
Trim removes exactly what Go's own trim would remove — files and executable-entry directories named *-a or *-d inside the 256 two-hex-digit subdirectories — only with a much shorter cutoff. README, trim.txt, testexpire.txt and fuzz/ are never touched.
The idea comes from cloudx-io/setup-go's trim-gocache post step; it is reimplemented here so the template takes no third-party action and needs no post hook (CI saves the cache in an explicit step, so the trim simply runs before it).
Index ¶
Constants ¶
const MtimeInterval = time.Hour
MtimeInterval is cmd/go's mtimeInterval: an entry's mtime is refreshed on use only if it is at least this old. A cutoff must leave at least this much slack before the run's start.
Variables ¶
This section is empty.
Functions ¶
This section is empty.