Safeguard
Security Guides•

What Go supply chain settings should a new service start with?

A starting checklist for a new Go service: commit go.sum, pin the toolchain, scope private modules, scan with reachability, and gate pull requests.

Safeguard Security Team
3 min read

Start a new Go service by committing go.mod and go.sum, pinning the toolchain in CI, scoping GOPRIVATE tightly, leaving the checksum database on, scanning with reachability, and gating pull requests that change dependencies. These settings cost little on day one and are hard to retrofit.

The checklist

AreaSettingWhy
RepositoryCommit go.mod and go.sumGo uses go.sum to verify downloaded modules
ToolchainPin in the build image, GOTOOLCHAIN=local in CIAvoid surprise compiler changes
Checksum databaseKeep GOSUMDB onSame contents for every user
Private modulesNarrow GOPRIVATE patternAvoid skipping verification for public code
VCS toolsConsider GOVCS limited to gitSmaller fetch surface
ToolsUse the tool directiveVersioned dev tools
ScanningReachability aware scan on every PRFewer, better findings
ReleaseRecord go version -m outputTrace what shipped

Steps

  1. Create the module and commit both go.mod and go.sum with the first dependency.
  2. Choose the Go version and set the go line. Add a toolchain line for the patch release you test with. See go line vs toolchain line.
  3. In CI, use a base image with that Go version and set GOTOOLCHAIN=local.
  4. Configure GOPRIVATE for your own organization only. Read what each private module variable does.
  5. Add a check that go.mod and go.sum are tidy. Run go mod tidy and fail the job if files change.
  6. Add vulnerability scanning on each pull request, using a tool that applies reachability. Compare with version matching as described in why govulncheck reports fewer issues.
  7. Add a review rule: go.mod, go.sum and CI configuration changes need a second reviewer.
  8. Write down who owns dependency updates and how often they run.
  9. At release, store the dependency list read from the binary with the release record.

What to avoid from the start

  • Setting GOSUMDB=off or wide GOINSECURE patterns to get past a first error. See what each setting disables.
  • Committing local path replace directives.
  • Installing developer tools with @latest in scripts.

Why Go helps you here

Go has no install scripts, no package repository accounts and builds locked by the main module's go.mod, per the Go team's supply chain article. Those are real advantages. The remaining risk sits in what you import, how you update, and how you configure the toolchain, which is what the checklist covers.

Try it yourself

Click through it at your own pace, or open it full screen. Look at how a pull request is held when a dependency finding crosses the policy.

Where Safeguard fits

Safeguard provides SBOM and dependency scanning, reachability analysis, and policies and gates for pull requests. You can start with a free scan.

Quick check

Is go.sum needed if go.mod pins versions?

Yes. go.mod chooses versions, and go.sum records the hashes used to verify them.

Should CI allow toolchain downloads?

Preferably not. Pin the toolchain in the image and set GOTOOLCHAIN to local so changes are deliberate.

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.