How to Fix 'missing go.sum entry for module providing package' in Go

intermediate🔷 Go2026-06-19| Go (Golang) 1.11+ using Go Modules on Linux, macOS, or Windows.

Error Message

missing go.sum entry for module providing package <package_name>; to add it, run: go mod download <package_name>
#go#golang#go-modules#go.sum#dependency-management

The Error Message

You are likely trying to run go build, go test, or go run when the compiler throws this roadblock at you:

missing go.sum entry for module providing package <package_name>; to add it, run: go mod download <package_name>

Why This Happens

Go modules use the go.sum file as a security layer. It contains the expected cryptographic hashes of your dependencies. If you import a package in your code, or if a dependency is listed in go.mod but its specific hash is missing from go.sum, Go refuses to compile. This prevents "dependency hijacking" where a remote repository might swap out code without you knowing.

Common triggers include:

  • Manually editing go.mod to add a version.
  • Git merge conflicts in go.sum that were resolved incorrectly.
  • Using go get in a way that didn't properly sync the checksums.
  • A CI/CD environment that has restricted network access and can't fetch new checksums.

Step-by-Step Fixes

1. The Standard Cleanup (The "Go-To" Fix)

In 90% of cases, you don't need to download packages individually. You need to synchronize your module state. Run this command in your project root:

go mod tidy

This command does two things: it adds missing module requirements for imported packages and removes requirements that don't have any imports. Most importantly, it fills in the missing entries in go.sum.

2. Force Download Specific Package

If go mod tidy doesn't solve it, or if you are targeting a specific module that seems stuck, follow the suggestion in the error message:

go mod download <package_name>

Replace <package_name> with the actual path shown in your error (e.g., github.com/google/uuid). This forces Go to fetch the module and update the checksum file.

3. Handling Private Repositories

If the missing package is from a private GitLab or GitHub repo, your Go toolchain might be failing to fetch the checksum because it's trying to hit the public Google Checksum Database (sum.golang.org), which doesn't have access to your private code.

Set your GOPRIVATE environment variable to bypass the proxy and checksum database for your internal domains:

# For macOS/Linux
export GOPRIVATE=github.com/your-org/*

# For Windows (PowerShell)
$env:GOPRIVATE="github.com/your-org/*"

After setting this, run go mod tidy again.

4. The "Nuclear Option" (Local Cache Clear)

If your go.sum looks correct but you keep getting the error, your local module cache might be corrupted. This is rare but happens during interrupted downloads.

go clean -modcache
go mod tidy

Warning: This will delete all downloaded modules on your machine. The next go mod tidy will take a while as it re-downloads everything.

5. Fix for Vendored Projects

If your project uses a vendor/ directory (common in legacy or high-compliance environments), ensure your vendor folder is in sync with your go.mod:

go mod vendor
go mod tidy

Verification: How to confirm the fix worked

Once you've run the fixes, verify your environment is clean by running a build or a test suite across the entire project:

# Check if the project compiles without errors
go build ./...

# Or run tests to ensure dependencies are fully resolved
go test ./...

If these commands exit without the missing go.sum entry error, you're back in business.

Pro-Tips for Prevention

  • Commit your go.sum: Never add go.sum to .gitignore. It is essential for reproducible builds and security.
  • CI/CD Checks: Add go mod tidy --check (or go mod download) to your CI pipeline to catch missing entries before they hit production.
  • Editor Integration: Use VS Code with the Go extension or GoLand. They usually run go mod tidy automatically on save, preventing this error from ever appearing.

Related Error Notes