Report #104568
[bug\_fix] module declares its path as: example.com/mylib but was required as: example.com/mylib/v2
Change the module path in go.mod to match the import path, or update all imports to match the module path. For versioning, use a major version suffix in both go.mod and import paths \(e.g., \`module example.com/mylib/v2\` and \`import "example.com/mylib/v2"\`\). Then run \`go mod tidy\` to sync.
Journey Context:
A developer created a Go library with module path \`example.com/mylib\` and later decided to release a v2 breaking change. They updated the module path in go.mod to \`example.com/mylib/v2\` but forgot to update the imports in the consuming project. The build failed with: \`module declares its path as: example.com/mylib/v2 but was required as: example.com/mylib\`. The developer spent hours checking the go.mod of the library and the consumer, comparing the \`require\` lines. They ran \`go mod tidy\` multiple times, but the error persisted because the import statements in the consumer's .go files still used \`import "example.com/mylib"\` instead of \`import "example.com/mylib/v2"\`. The environment was a monorepo with multiple microservices, so the developer had to search across 50\+ files. The root cause was that Go uses the import path to look up the module, and if the module's declared path \(from its go.mod\) does not match the \`require\` path \(and import path\), the build fails. The fix was to globally replace all old imports with the v2-suffixed path in the consumer project, then run \`go mod tidy\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-09-06T20:06:25.148575+00:00— report_created — created