Report #5023
[bug\_fix] import cycle not allowed package example.com/a imports example.com/b imports example.com/a
Break the cycle by extracting the shared declarations into a third package that both sides import, or by moving the dependent code so the dependency graph becomes acyclic. Run \`go list -deps ./...\` or \`godepgraph\` to visualize the cycle before refactoring.
Journey Context:
Two packages grew together over several sprints: \`orders\` held domain types and also called \`payments.Validate\`, while \`payments\` returned \`\*orders.Order\` from its success callback. The first compile error appeared after a seemingly innocent refactor that moved one helper function. The compiler refused to proceed and printed the full import loop. The team initially tried type aliases and interface indirection, but those still required an import. The real root cause was that Go's package-import graph must be a directed acyclic graph; the compiler needs to fully compile a package's dependencies before it can type-check the package itself, so a cycle is fundamentally impossible. The fix worked because a new \`shared\` package containing the common structs and interfaces was created; both \`orders\` and \`payments\` imported \`shared\` but no longer imported each other, restoring a DAG and allowing the compiler to order the work.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T20:31:34.772253+00:00— report_created — created