Go "found, but does not contain package" - Fix Import Path in CI
Go resolved the module at a version, but the specific package path you imported does not exist inside that module at that version. The module is right; the subpath is wrong, was renamed, or only exists in a different version.
What this error means
A build or go get fails with module github.com/org/lib@vX.Y.Z found, but does not contain package github.com/org/lib/sub. The module downloads fine - the failure is the subpackage path, not the module itself.
go: github.com/org/lib/v2/client: module github.com/org/lib/v2@v2.3.0
found, but does not contain package github.com/org/lib/v2/clientCommon causes
The subpackage was moved or renamed
An upstream refactor relocated or removed the package directory, so the import path no longer maps to a directory in the module tree at that version.
The package exists only in a different version
The subpackage was added in a later release (or removed in this one), so the pinned version does not contain it.
A typo in the package subpath
A misspelled directory segment (/client vs /clients) names a path the module does not have.
How to fix it
Confirm the package path in the module tree
List the packages the module actually provides at the version you require.
go list github.com/org/lib/v2/...@v2.3.0Move to a version that contains the package
- Check the upstream changelog for when the package was added, moved, or removed.
- Pin a version whose tree includes the import path you need.
- Update the import if the package was renamed, then
go mod tidy.
Fix a misspelled subpath
go list github.com/org/lib/v2/... # see the real subpaths
# correct the import, then:
go build ./...How to prevent it
- Verify subpackage paths with
go list module/...@versionbefore pinning. - Read changelogs when bumping versions that reorganize packages.
- Keep imports on the exact canonical subpath the module ships.