Any difference between a subpackage and a totally different package?

3,177 views
Skip to first unread message

josvazg

unread,
Jul 20, 2011, 5:31:40 PM7/20/11
to golang-nuts
I mean, does "package/subpackage" have any special access rights to
things unexported in "package", that obviously a"notherpackage" does
NOT have?

Or is there any other difference between using "package/subpackage" or
"otherpackage"?

Kyle Lemons

unread,
Jul 20, 2011, 5:35:19 PM7/20/11
to josvazg, golang-nuts
I mean, does "package/subpackage" have any special access rights to
things unexported in "package", that obviously a"notherpackage" does
NOT have?
nope.
 
Or is there any other difference between using "package/subpackage" or
"otherpackage"?
it's for clarity, organization, and to conceptually group packages to make humans lives easier; the compiler doesn't really care.

Jeremy Wall

unread,
Jul 20, 2011, 5:35:41 PM7/20/11
to josvazg, golang-nuts

According to: http://golang.org/doc/go_spec.html#Packages there are no
special access rights. There is no such thing as a subpackage just a
subdirectory and they aren't the same thing in Go.

josvazg

unread,
Jul 21, 2011, 3:19:44 AM7/21/11
to golang-nuts
Ok, then they are also separate compilation units, the subpackage can
be imported without the parent package and viceversa
right?

Only the code from the imported package will be linked into the final
executable.
correct?

On Jul 20, 11:35 pm, Jeremy Wall <jw...@google.com> wrote:
> On Wed, Jul 20, 2011 at 4:31 PM, josvazg <josv...@gmail.com> wrote:
> > I mean, does "package/subpackage" have any special access rights to
> > things unexported in "package", that obviously a"notherpackage" does
> > NOT have?
>
> > Or is there any other difference between using "package/subpackage" or
> > "otherpackage"?
>
> According to:http://golang.org/doc/go_spec.html#Packagesthere are no

John Asmuth

unread,
Jul 21, 2011, 8:12:37 AM7/21/11
to golan...@googlegroups.com


On Thursday, July 21, 2011 3:19:44 AM UTC-4, josvazg wrote:
Ok, then they are also separate compilation units, the subpackage can
be imported without the parent package and viceversa
right?

Only the code from the imported package will be linked into the final
executable.
correct?


Right - the import path only specifies where to find the package's .a file. The fact that there are other .a files with similar import paths is irrelevant.
Reply all
Reply to author
Forward
0 new messages