Go "cannot find module providing package" - Fix in CI
You import a package, but no module in go.mod provides it. Either the dependency was never added with go get, the import path is wrong, or you are in module mode without the require it needs.
What this error means
A build fails with no required module provides package <path> and a hint to run go get. The code references a package, but the module graph has nothing that supplies that import path.
app/main.go:5:2: no required module provides package
github.com/example/util; to add it:
go get github.com/example/utilCommon causes
Dependency not added to go.mod
The import was written but go get (or go mod tidy) was never run, so go.mod has no require line that provides the package.
Wrong or renamed import path
A typo, a moved repository, or a new major version path (/v2) means the import does not resolve to any real module.
GOFLAGS=-mod=vendor without a vendored copy
In vendor mode, a package missing from vendor/ cannot be found even though it exists upstream.
How to fix it
Add the dependency
Fetch the module that provides the import and record it in go.mod/go.sum.
go get github.com/example/util
go mod tidyCheck the import path and major version
- Confirm the path matches the upstream repository exactly.
- For v2+ modules, the import path must include the major version suffix (
/v2). - If the repo moved, update the import to its new canonical path.
Vendor the dependency if you build with -mod=vendor
go mod tidy
go mod vendor
go build -mod=vendor ./...How to prevent it
- Run
go mod tidyso every import has a matching require. - Use the exact canonical import path, including the
/vNmajor suffix. - Keep
vendor/regenerated when building in vendor mode.