Report #30143
[bug\_fix] go: module example.com/[email protected] found, but does not contain package example.com/foo
Change the import path in the Go source code to match the actual directory structure of the repository \(e.g., \`example.com/foo/bar\` instead of \`example.com/foo\`\).
Journey Context:
A developer runs \`go get example.com/[email protected]\` and it succeeds, updating go.mod. They add \`import "example.com/foo"\` to their code, but \`go build\` fails, stating the module was found but does not contain the package. They check the go.mod and see the module path is correct. They might try running \`go mod tidy\` or \`go get -u\`, but the error persists. The root cause is confusing a \*module\* path with a \*package\* path. A \`go.mod\` defines the module prefix, but the actual importable package path must point to a directory containing \`.go\` files. If the repository's root only has a \`go.mod\` and the actual code is in a subdirectory like \`bar/\`, the import path must include that subdirectory. The fix works because it aligns the import statement with the exact directory structure of the repository, allowing the Go tool to locate the Go source files within the downloaded module.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T04:59:00.380861+00:00— report_created — created