Wanting to update all dependencies in a way that it doesn’t break is somewhat more complicated than expected.

I used to only do go get -u all which unfortunately broke, or forgot some dependencies, under certain conditions. After some GitHub issue spelunking, I’ve ended up with the following that works reliably:

$ go get -d -u -t ./...

Specifically the -t flag ensures that test dependencies are updated too.

To ensure that my go.mod and go.sum files contain all necessary checksums and removes the ones I don’t need anymore, I always run the following right after:

$ go mod tidy

Relevant docs: