It doesn't seem messy to me.
Define your interfaces in a high-level package that the other packages
in your project depend on, then they can just pass interface values
around. That's the idiomatic way of doing it.
It's also likely that you're over-compartmentalizing. You say it's
"nicely modular," but now you're having dependency problems? That
doesn't sound modular to me. A Go package typically contains a lot
more than a Java or C++ class would. If you put all your components in
the one package your dependency issues will go away.
Of course, it's hard to say not having seen any of the code.
Andrew
I would call that "maintainable", but having complex dependencies also
reduces that maintainability.
For me is:
Write programs that do one thing and do it well. :-)
--
André Moraes
http://andredevchannel.blogspot.com/
Packages are units of code to import. If you cannot import A without B and vice versa (they have a circular dep), they need to be one package.The fact that we get namespaces from packages too is, I think, a little unfortunate, but I don't see a better way to deal with it at the moment.
--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I
On Jul 26, 2014 9:51 AM, <james...@gmail.com> wrote:
>
> Having to have a single package with 30+ files in it is completely unmanageable for any realistic project.
>
net/httphas 47 files.
http://talks.golang.org/2013/bestpractices.slide#17
> Just because some people are comfortable with over engineered complex code doesn't mean all developers like to work like that.
>
> On Tuesday, 31 January 2012 13:40:43 UTC, John Asmuth wrote:
>>
>> Packages are units of code to import. If you cannot import A without B and vice versa (they have a circular dep), they need to be one package.
>>
>> The fact that we get namespaces from packages too is, I think, a little unfortunate, but I don't see a better way to deal with it at the moment.
>
In the general case a dependency cycle can be unresolvable in many languages, it's not much Go specific. (Think a type T T class of problems).
In some other cases, there is a solution, but at the cost of incremental/separate compilation not being available anymore. That scales badly.
Go is simply honest: circular dependency is a design error.
-j
I don't believe it is always an error in design. There is nothing wrong with separating code into multiple packages to aid clarity and therefore each package could have some references to each other.This would only be an error in design if each package was a separate logical module.Clearly the previous commenters you refer to don't understand the distinction between a separate package for clarity and a separate logical component.