Currently my code-base have just 1 level of packages , due to the increase in number of components it would make much sense if I use sub packages.Is there any code refactoring tools I could use to achieve this.
Package_1/
-- File 1
-- File 2
-- File 3
-- File 4
Package_2/
-- File 5
-- File 6
-- File 7Target structure
Package_1
/subpackage1
-- File 1
-- File 2
/subpackage2
-- File 3
-- File 4
Package_2/
/subpackage3
-- File 5
-- File 6
/subpackage4
-- File 4 I tried gomvpkg https://godoc.org/golang.org/x/tools/cmd/gomvpkg but doesnot support moving files from same package to different package.
Although this e-mail has been scanned for viruses, HiFX cannot ultimately accept any responsibility for viruses and it is your responsibility to scan attachments (if any).
Before you print this email or attachments, please consider the negative environmental impacts associated with printing.Currently my code-base have just 1 level of packages , due to the increase in number of components it would make much sense if I use sub packages.Is there any code refactoring tools I could use to achieve this? I tried gomvpkg https://godoc.org/golang.org/x/tools/cmd/gomvpkg but doesnot support moving files from same package to different package.
I advice caution, Go is not Java and does not permit circular dependencies. The more packages you have, the greater the chance you have of creating a circular dependency.
For example, net/http contains both http client and server facilities, because they both relate to the use of http. The prevailing style in other languages would have these placed in separate packages, one for client, one for server, and a third for things which are common to both. I think this is unnecessary.
On 14 December 2016 at 15:13, Dave Cheney <da...@cheney.net> wrote:For example, net/http contains both http client and server facilities, because they both relate to the use of http. The prevailing style in other languages would have these placed in separate packages, one for client, one for server, and a third for things which are common to both. I think this is unnecessary.There's a case to be made here for the combined power of internal packages and aliases (as proposed for Go 1.8). From the user's perspective, a single net/http package makes sense, but for the maintainers, breaking it up may lighten their burden.Within Google, the Go implementation of our in-house RPC system is a complex beast that would benefit from a little modularity, but we can't break the package up without changing its API. With aliases, it would be possible to define separate internal packages for common declarations, for clients, and for servers, and then define a "facade" package that exposes just the API.
I realize you are no fan of the aliases proposal, but I think it provides real opportunities to solve problems of "programming in the large" that aren't just about temporary refactoring.
On Dec 14, 2016, at 12:50 PM, 'Alan Donovan' via golang-nuts <golan...@googlegroups.com> wrote:On 14 December 2016 at 15:13, Dave Cheney <da...@cheney.net> wrote:For example, net/http contains both http client and server facilities, because they both relate to the use of http. The prevailing style in other languages would have these placed in separate packages, one for client, one for server, and a third for things which are common to both. I think this is unnecessary.There's a case to be made here for the combined power of internal packages and aliases (as proposed for Go 1.8). >From the user's perspective, a single net/http package makes sense, but for the maintainers, breaking it up may lighten their burden.Within Google, the Go implementation of our in-house RPC system is a complex beast that would benefit from a little modularity, but we can't break the package up without changing its API. With aliases, it would be possible to define separate internal packages for common declarations, for clients, and for servers, and then define a "facade" package that exposes just the API.
In my experience it is very common for circular dependencies to arise
not because
of something in a package that I'm using directly, but because of
something semi-related that
happens to sit in the same package.
How do aliases help this situation? In my view they'll just obscure the true source of the declaration.
How do aliases help this situation? In my view they'll just obscure the true source of the declaration.