Safeguard
Developer Tools•

How do you update Go dependencies safely?

List available Go module updates, upgrade one module at a time with go get, tidy, review go.sum, test, and confirm the fix. A repeatable update routine.

Safeguard Security Team
3 min read

Update Go dependencies in small steps. List what is outdated with go list -m -u all, upgrade one module with go get module@version, run go mod tidy, review the go.mod and go.sum diff, test, then rescan. Small changes make failures easy to trace and review easy to do.

The commands

From the Go managing dependencies guide:

  • go list -m -u all lists all dependencies with the latest available versions. For one module, use go list -m -u example.com/theirmodule.
  • go get example.com/theirmodule@v1.3.4 upgrades to a specific version. @latest takes the newest.
  • go get with a commit or branch produces a pseudo-version, which you usually want to avoid in production.
  • go mod tidy adds missing modules and removes unused ones.
  • Go authenticates each download, and if a module changed after publication you get a security error.

Steps

  1. Branch. Run go list -m -u all and pick the modules to update, starting with ones that have security fixes.
  2. Upgrade one module: go get example.com/theirmodule@v1.3.4. Read its release notes first.
  3. Run go mod tidy.
  4. Inspect git diff go.mod go.sum. Expect the target module and possibly a few transitive bumps. Question anything surprising, such as a new module you did not ask for or a jump in the go line.
  5. Build and test: go build ./... and go test ./....
  6. Rescan for known vulnerabilities and confirm the target finding is gone.
  7. Open a pull request with the module, old and new versions, and the reason.

Why one at a time

ApproachUpsideDownside
Upgrade everything with one commandFastHard to find what broke, large review
One module per pull requestEasy review and rollbackMore pull requests
Group by team or riskBalanceNeeds a convention

Because Go uses minimal version selection, an upgrade raises only what the new version requires, which keeps diffs smaller than in ecosystems that re-resolve everything.

Watch the go line

An upgrade can raise your go directive, since a module may require a newer Go version. Since Go 1.21 that line is a mandatory minimum, and with default settings the toolchain may switch. Read what GOTOOLCHAIN does before merging such a change.

Try it yourself

Click through it at your own pace, or open it full screen. Look at how a fixed version is proposed and what the change touches.

Where Safeguard fits

Safeguard offers autonomous remediation with fix pull requests. It is off by default, with every category set to Manual, so changes need your approval. A free scan shows what is outdated.

Quick check

How do I see which modules have updates?

Run go list -m -u all.

Should I commit go.sum with an update?

Yes. Commit both go.mod and go.sum together.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.