A Go monorepo build is slow because the Go build cache is cold. Optimize.
IntermediateScenarioSpeed, Caching & Cost
Answer
Situation read → Two caches matter: module download cache and build cache.
What I'd do →
actions/setup-go@v5withgo-version-file: go.mod(caching on by default, keyed ongo.sum).- Set
cache-dependency-pathfor multiple modules:"**/go.sum". - Restore-only on PRs, save on
mainif cache churn is a problem.
Why → The build cache (~/.cache/go-build) avoids recompiling unchanged packages.
Interview tip → Know the two directories: GOMODCACHE and GOCACHE.
More on Speed, Caching & Cost
`npm ci` takes 4 minutes on every run. Fix it.BeginnerDocker builds take 12 minutes even when only one line of code changed. Speed them up.IntermediateThe repo hits the 10 GB cache limit daily and hit rates are poor. What do you change?IntermediatemacOS jobs are 60% of your bill. What are your options?IntermediateA job sometimes hangs and burns 6 hours. How do you stop it happening again?BeginnerYour PR matrix is 3 OS times 4 versions (12 jobs). How do you cut cost without losing coverage?Advanced