Skip to content
Latchkey

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 output
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/client

Common 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.

Terminal
go list github.com/org/lib/v2/...@v2.3.0

Move to a version that contains the package

  1. Check the upstream changelog for when the package was added, moved, or removed.
  2. Pin a version whose tree includes the import path you need.
  3. Update the import if the package was renamed, then go mod tidy.

Fix a misspelled subpath

Terminal
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/...@version before pinning.
  • Read changelogs when bumping versions that reorganize packages.
  • Keep imports on the exact canonical subpath the module ships.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →