4 ms·
Go forbids cyclical imports, and, in most cases, I really appreciate it. Makes the code much simpler to reason about
by bbkane 3y ago
Go forbids cyclical imports, and, in most cases, I really appreciate it. Makes the code much simpler to reason about
- colejohnson66 3y agoAs someone who doesn't use Go, how would one handle a situation where two modules actually depend on each other? For example, a parent object owning a child object is normal, but what if that child object sometimes needs a (weak) reference to the parent?
- nikbackm 3y agoJust put them in the same module?
- dale_glass 3y agoWhat if the child is an user-implemented piece of code and the parent is in a library?
- Kranar 3y agoThen there wouldn't be a circular dependency. If the parent is in a library and was written independently of the child, then the parent could not possibly import the child.