Updating the binary is intentional, so that `go build` has consistent behavior.
The way to handle this in a Makefile is to use the move-if-change
dance, which looks more or less like
real-target: stamp-target; @true
stamp-target: ...
go build -o temporary-target ...
if cmp temporary-target real-target; then \
rm temporary-target; \
else \
mv temporary-target real-target
fi
touch stamp-target
With this technique stamp-target will be rebuilt if any of its
dependencies change, and real-target will be rebuilt only if the build
generated a file that was different in some way.
Ian