I'm running a project using Go Modules with 1.11.4 on Ubuntu, running in WSL. My problem is that I'm having getting incremental builds to work as I expect. Perhaps this is due to me misunderstanding how it's supposed to, but I'd be glad if someone could clarify if that is the case.
Just as an example, if I do go build ./...
then everything is built, as expected.
If I now do go build ./...
again without any changes, my expectation was that due to the incremental builds, this time nothing would be built. But it builds everything again. I tried doing go build -i ./...
(even though my understanding is that -i isn't needed anymore from 1.10), but the result is the same. This has been puzzling me for some time, as after reading the documentation I indeed expected the go build
command to produce incremental builds.
The other day I realized that if instead I do go install ./...
first, and then go install ./...
again a second time, the second time around nothing is built, as I would expect. If I change a single module and run go install ./...
again, then only that module is rebuilt, again what I would expect. So this gives me incremental builds.
So my questions are
1) Did I misunderstand go build ./...
and how it handles incremental builds? Do I need to use go install
instead?
2) Typically, we build the modules one by one, using the -o
flag to specify an output path. Using go install
instead, there is no -o
option to specify an output path. Is there anything I can do to achieve something similar to -o
using go install
?
Thanks!