You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package state
import "city"
type State struct {
ID uint64
Name string
Cities []city.City // The list of all cities in this state
}
...
package city
import "state"
type City struct {
ID uint64
Name string
State *state.State // The state to which the city belongs
}
There is a problem of cyclic import, how to handle this kind of situations?
You can say, that we can put state and city into the same package, but...
if we add more realistic cases and examples, this is not a solution anymore:
type Department struct {
City *city.City // Where is department located
}
and modify type City struct to following:
type City struct {
// previous fields
Departments []department.Department
}
Thank you!
The text was updated successfully, but these errors were encountered:
Sorry for late response,
So after figuring this problem a few months ago, I make many changes to all my entire project. But I forgot to update this one.
Hi!
Lets say, we have a:
There is a problem of cyclic import, how to handle this kind of situations?
You can say, that we can put
state
andcity
into the same package, but...if we add more realistic cases and examples, this is not a solution anymore:
and modify
type City struct
to following:Thank you!
The text was updated successfully, but these errors were encountered: