3 ms·
>Java allows circular imports between packages. > >Go does not. Huh? As a package maintainer for a lot of Go stuff, I had to deal with tricky cyclic depende
by eclipseo76 8y ago
>Java allows circular imports between packages.
>
>Go does not.
Huh? As a package maintainer for a lot of Go stuff, I had to deal with tricky cyclic dependencies several times, especially in Google own Go packages like golang.org/x/build and google cloud.
- rat9988 8y agoWhat do you mean by "deal with"?
- thanatos_dem 8y agoThey had to take it into an alley and kill it, mafia style. More seriously, they probably means find ways to restructure packages and extract shared dependencies into subpackages to avoid cyclical dependencies.
- rat9988 8y agoWhich in turn means that go doesn't allow it, hence the original point.
- eclipseo76 8y agoGo expects to have all dependencies available at any time, downloading them from Internet if necessary. Cyclic dependencies are not a problem in that case because all dependencies are built together. Packaging for a distro requires building Go packages isolated from the network in a chroot and having all the dependencies previously built in the same manner. So it is an iterative process, building blocks by building blocks. If you have a cyclic dependencies, you can't build iteratively, and you'll have to excise certain part of the code to eliminate the cycle.