Go mod often fails the first time. It generates spurious errors like missing go.sum entry
. And so I often end up running this sequence twice in a row:
go mod download
go mod vendor
(recommended)go mod tidy
Can Go please fix the mod system? Not only is it tiring to repeat the sequence twice, doubling my labor across very many Go projects. But it’s also silly to have to invoke three distinct commands to update the Go caching system.
There should really be a simple command like go mod refresh
that performs each of these low level steps. It should read an optional boolean parameter that controls whether or not to vendor, from the go.mod
configuration file. It should never requiring repeating the command again to resolve low level recoverable errors.
Yet another case in favor of a single, unified refresh command is the fact that multiple commands introduce subtle bugs into larger scripts. POSIX shells may apply &&
and/or set -e
to ensure that genuine errors propagate through downstream systems, such as CI/CD jobs. But this syntax is not portable beyond *nix environments. Command Prompt and PowerShell struggle to reliably bubble up accurate exit codes. Combining these operations into a single command makes scripts that run go mod
… commands much more reliable. Without having to resort to shoving everything into a more verbose mage Go task.