Detecting changes to know which main package needs a rebuild
I have a project, structured as a monorepo, consisting of multiple microservices. Each microservice is in a 'cmd/<microservicename>/' directory. They all rely on the logic of the same code.
The problem I have is knowing when I have to rebuild a specific microservice. For production, I will always rebuild all and deploy the ones that have changed, but during testing, I would like to speed up the process and only rebuild the services that are affected by the changes.
Say I have three main packages, two depend on the package 'foo'. When foo is changed, I would like to detect the need to rebuild two of the micro services, but the third which is unaffected can stay as is until the code has been committed and built by the CI.
At the moment it is easy to forget some service and I get bugs during testing until I realise that one service depended on the changes and was not updated.
Are there any existing tools or linters that would allow me to detect this? The detection does not need to rely on any previously built binaries, but rather check the git changes and report which main packages are affected by the changes.
A bonus would be detecting if a dependency version has changed in the go.mod and would also tell me to rebuild.
Apart from detecting during testing, it would give an overview of what parts of the system will change during the next deployment.
Posted Oct 6, 2025, 7:12 PM UTC