Package organization

Go is very simple, i’m using for a very short time (4 months), and already everything is very natural: channels, go routines, etc…
But, there is one thing that still very hard, organize packages with lot’s of interconnections.

Came from C# world and my problem is that i’m trying to use their semantics in Go.
For example, there is a package called repo, all my data access is there. If everything stay at the same package, no problem with cyclic dependencies, but, it’s freaking hard to maintain, everything stay very coupled and the package grows wildly.

Found just one way to do, all entities and interfaces stay at the root package(repo) and created subpackages that holds the logic. Don’t know why, but still don’t like this approach.
And there is one thing, the place repo is initialized, i need to call the subpackages and inject then in repo manually, otherwise, cyclic import.

Really, this is the only thing i really hate in go. Project organization in other languages is tons of time easier for me (in mid/large projects).

My project is only at the beginning. I have 10 ‘repos’ inside the repo package, i’m afraid that the organization get out of control when the repo quantity increase (20+).
Even with only the entities and interfaces in one place, still weird.

Any suggestion or am i right in what i’m doing?

1 Like

Most people has been discussing about your problem: https://forum.golangbridge.org/search?q=package%20dependency%20manager

To be specific, there is a wiki about it how to handle it here: https://github.com/golang/go/wiki/PackageManagementTools

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.