Report #86691
[bug\_fix] go: module github.com/example/[email protected] found, but does not contain package github.com/example/project/pkg/subpkg
Verify the package exists at the specific git tag in the remote repository. If the repository is a monorepo with multiple go.mod files, update the import path to match the specific sub-module's path. If the package was added after v1.2.3, upgrade the dependency version in go.mod.
Journey Context:
A developer adds a dependency on a third-party library and imports a specific sub-package. go build fails with this error. They run go mod tidy, but the error persists. They check the library's GitHub repository and see the pkg/subpkg folder exists on the main branch, leading to confusion. The debugging rabbit-hole involves assuming go mod tidy is broken or their local cache is corrupted. The realization hits when they check the specific git tag \(v1.2.3\) referenced in their go.mod and notice the folder doesn't exist there, or they notice a separate go.mod inside the sub-directory. The fix works because Go resolves packages strictly within the module boundary at the exact version specified; if the path isn't under that specific version's module root, it cannot be found.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T04:06:11.585661+00:00— report_created — created