On Tue, Feb 28, 2017 at 10:55 PM, Basile Starynkevitch
<[email protected]> wrote:
>
> On Wednesday, March 1, 2017 at 7:17:42 AM UTC+1, Ian Lance Taylor wrote:
>>
>> On Tue, Feb 28, 2017 at 12:44 PM, Basile Starynkevitch
>> <[email protected]> wrote:
>> > Can the packages defined in one plugin be visible from plugins loaded
>> > afterwards? I'm thinking of a dlopen with  RTLD_GLOBAL flag in C
>> > parlance.
>>
>> I'm not sure this really makes sense in a Go context.  I'm not sure
>> how you would refer to those symbols.
>
>
> The scenario would be the following:
>
> a plugin P1 defines the P1_foo () function. P1 is loaded (and I would like
> the name to be visible afterwards, see below). We can assume that the
> loading program & process does not have any P1_foo in it.
>
> later, another plugin P2 defines the P2_bar() function which calls P1_foo(),
> and I would like that to mean the P1_foo() function inside P1. It seems that
> this is not possible currently. (of course loading P2 before loading P1
> should fail). I don't understand why would that not make any sense.

Go, unlike C, does not have the notion of an external symbol that is
defined somewhere else to be discovered at link time.  In Go all
symbols come from imported packages.  So if P2 does not import P1,
then P2 can not refer to P1_foo.

That said, you could probably get something like this to work by using
the //go:linkname compiler directive, which is available if you import
the unsafe package.  See https://golang.org/cmd/compile.

Ian

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to