import cycle
A situation where two or more packages import each other, directly or in a loop, which the Go compiler refuses to build.
In more detail
Go reports import cycle not allowed and stops. The rule forces clear layering: shared types move to a lower package that both sides import. It is annoying the first time and saves you from tangled designs later.
Related terms
- import declaration — The line near the top of a Go file that names the packages the file uses, such as import "fmt".
- Go package — A folder of Go source files that are compiled together and share one package name, which other code imports as a unit.
Taught in
- Go Workspaces and Modules — Concurrent Systems Programming with Go