cross compiling go and go install v. go build and caching the results

I am following Dave Chaney’s advice from here

I am on OSX using go installed from homebrew, so the writability of GOROOT in /usr/local/Cellar… is not an issue as stated in Dave’s post.

How can I reap the benefit of cached package builds when cross compiling?

`go install` uses the cache and places the resulting binary in $GOPATH/bin/$GOOS_$GOARCH/ instead of in $GOPATH/bin/

Of course, now that I’m writing this as a blog post, for myself, I see this is already mostly documented in the link from Dave’s post to medium: including a nice command to cross compile the std library in the system cache.

You can populate the stdlib cross compile pkg cache in GOROOT by running this command, changing env vars for each platform you wish to target:

GOOS=darwin GOARCH=amd64 sudo -E go install std

Now your cross compiles do not have to recompile the standard library packages.

Continuous Delivery via Unattended Upgrades

I’ll be the first to admit that this is pretty slow for continuous delivery, as the default configuration for unattended upgrades is daily. Adjust the cron configuration at your discretion.


  • CI system which builds apt source packages and dputs them to a PPA.
  • Machine instances configured with these PPA and with unattended-upgrade

The unattended-upgrades package, by default only installs security updates. We can configure it to install updates to packages in our PPA by adding the correct package origin to the config. We get the package origin from apt-cache policy.


$ apt-cache policy

500 trusty/main amd64 Packages
release v=14.04,o=LP-PPA-evarlast-experimental,a=trusty,n=trusty,l=ex per ee m3nt4l,c=main

Extract that LP-PPA-evarlast-experimental from that output and add it to a new section in /etc/apt/apt.conf.d/50unattended-upgrades. If you want, use `cat >> /etc/apt/apt.conf.d/50unattended-upgrades`

Unattended-Upgrade::Origins-Pattern {

Now when unattended-upgrades run, packages from that PPA are considered important enough that they will be installed.

The details for the configuration are in the README here: