Go "cannot find module providing package" - Fix in CI
Go found an import in your code but no module in go.mod provides it. Without a require directive it cannot resolve where the package comes from.
What this error means
A build fails with no required module provides package X; to add it: go get X or cannot find module providing package X. It means an import was added without recording the dependency.
app/main.go:6:2: no required module provides package github.com/google/uuid;
to add it:
go get github.com/google/uuidCommon causes
Import added without a require
New code imports a package, but go get/go mod tidy was never run to add the providing module to go.mod.
Typo in the import path
The import path is misspelled, so no real module matches and Go reports it as unprovided.
How to fix it
Add the missing module
- Run go get for the package, or go mod tidy to resolve all imports at once.
- Commit the updated go.mod and go.sum.
go mod tidy
git add go.mod go.sum
git commit -m "add missing dependency"Verify the import path
- Confirm the import path matches the real module path on the source host.
- Fix typos, then rebuild.
go build ./...How to prevent it
- Run
go mod tidyafter adding any import. - Copy import paths from the package docs to avoid typos.
- Add a tidiness guard to CI so missing requires fail early.