Build and Test Caching in Go
summary
Explains how Go caches at the package-level .a files using a SHA-256 checksum of all inputs, stores cache entries in a filesystem split into 256 directories, and uses action files that map input checksums to output checksums so rebuilds are avoided. Contrasts Make (mtime-based; misses rebuilds when commands change) and Bazel (hermetic, fast but heavy cache and long startup). Describes test caching that records syscalls getenv chdir stat open and rechecks those values before reusing cached test output, and CI advice to download and reupload $GOCACHE.
AI-written summary · about
chapters (6)
- 0:00Start
- 0:17Build and Test Caching
- 0:57Build caches: avoid 'slow to compute'
- 12:44Cache key: any input that can change
- 13:29Checksum
- 20:48Buuuut... tests aren't just source code! 1. Files in testdata dir 2. Environment variables (TZ, db config) 3. Subcommands
related talks
43mDeep dive into Go's build system
40mBuilding a Highly Concurrent Cache in Go: A Hitchhiker's Guide
06mLightning Talk – Test Result Caching at Dropbox
37mHow I made a powerful cache system using Go
26mBuilding Go with Bazel
34mAdvanced Testing Techniques in Go
44mGo Testing By Example
26mWrite Once, Compile Lots, Run Anywhere
