Skip to content

dev: rely on go compiler to decide if binary changed

Administrator requested to merge k/only-restart-changed-binaries into main

Created by: keegancsmith

In our dev environment when a file changes we recompile and restart all binaries that may depend on it. Previously we would compile to a temporary location and then only restart services if the binary changed. This had two downsides:

  • Go would do a lot of work since it still has to link the binaries to create the final executable.
  • The symbols service would always change due to cgo.

Now that we pass the final destination to go install, it inspects the binary and uses metadata in it to skip building/linking unless something has really changed.

To achieve this we rely on md5 summing the binaries before and after compilation. We can't rely on timestamps because go will always update them. This took a while to implement because bash is sadomasochism.

Co-authored-by: @eseliger

Merge request reports

Loading