# import cycle not allowed
package A
	imports B
	imports A

- **ID:** `go/missing-import-cycle-with-init`
- **Domain:** go
- **Category:** build_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

Two or more packages import each other directly or indirectly, creating a circular dependency that Go's compiler cannot resolve.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| go1.20 | active | — | — |
| go1.21 | active | — | — |
| go1.22 | active | — | — |

## Workarounds

1. **Extract the shared types or interfaces into a third package that both A and B import** (90% success)
   ```
   Extract the shared types or interfaces into a third package that both A and B import
   ```
2. **Use dependency injection: pass interfaces from A to B instead of importing A directly in B** (85% success)
   ```
   Use dependency injection: pass interfaces from A to B instead of importing A directly in B
   ```

## Dead Ends

- **Using a blank import (_ "package") to break the cycle** — Blank imports only trigger init() functions, they don't resolve the circular dependency in the type system. (95% fail)
- **Moving all code into a single package** — Violates separation of concerns; makes the codebase monolithic and harder to maintain. (80% fail)
- **Adding a new import that re-exports types from the cycle** — Creates a longer cycle or introduces a third package that still depends on the cycle. (90% fail)
