patterngoCritical
Import cycle not allowed
Viewed 0 times
allowednotcycleimport
Problem
I have a problem with
import cycle not allowed
It appears when I am trying to test my controller. Here is the output:
How do I read or understand this error? Where is the dependency wrong?
import cycle not allowed
It appears when I am trying to test my controller. Here is the output:
can't load package: import cycle not allowed
package project/controllers/account
imports project/controllers/base
imports project/components/mux
imports project/controllers/account
import cycle not allowed
package project/controllers/account
imports project/controllers/base
imports project/components/mux
imports project/controllers/account
import cycle not allowed
package project/controllers/account
imports project/controllers/base
imports project/components/mux
imports project/controllers/routes
imports project/controllers/baseHow do I read or understand this error? Where is the dependency wrong?
Solution
Here is an illustration of your first import cycle problem.
As you can see with my bad ASCII chart, you are creating an import cycle when
project/controllers/account
^ \
/ \
/ \
/ \/
project/components/mux <--- project/controllers/baseAs you can see with my bad ASCII chart, you are creating an import cycle when
project/components/mux imports project/controllers/account. Since Go does not support circular dependencies you get the import cycle not allowed error during compile time.Code Snippets
project/controllers/account
^ \
/ \
/ \
/ \/
project/components/mux <--- project/controllers/baseContext
Stack Overflow Q#28256923, score: 310
Revisions (0)
No revisions yet.