Re: [go-nuts] plugin - How to open and lookup for interface implementation

2016-11-07 Thread Mateusz Dymiński
Works! What a strange behavior... I'll create the issue - or even two on the github later today. Thanks Sebastien for your help! W dniu poniedziałek, 7 listopada 2016 12:58:52 UTC+1 użytkownik Sebastien Binet napisał: > > > > On Mon, Nov 7, 2016 at 12:44 PM, Seb Binet > wrote: > >> >> >> On

Re: [go-nuts] plugin - How to open and lookup for interface implementation

2016-11-07 Thread Seb Binet
On Mon, Nov 7, 2016 at 12:44 PM, Seb Binet wrote: > > > On Sun, Nov 6, 2016 at 8:21 PM, Mateusz Dymiński > wrote: > >> I haven't played with the plugin feature yet, but some things stand out >>> to me about your code and I wonder if it is correct or not. >>> Is there a difference in using go bui

Re: [go-nuts] plugin - How to open and lookup for interface implementation

2016-11-07 Thread Seb Binet
On Sun, Nov 6, 2016 at 8:21 PM, Mateusz Dymiński wrote: > I haven't played with the plugin feature yet, but some things stand out to >> me about your code and I wonder if it is correct or not. >> Is there a difference in using go build vs go run, in the same way as you >> can get bad behaviour us

Re: [go-nuts] plugin - How to open and lookup for interface implementation

2016-11-06 Thread Mateusz Dymiński
> > I haven't played with the plugin feature yet, but some things stand out to > me about your code and I wonder if it is correct or not. > Is there a difference in using go build vs go run, in the same way as you > can get bad behaviour using go run with more complex apps? Have you tried movin

Re: [go-nuts] plugin - How to open and lookup for interface implementation

2016-11-06 Thread Justin Israel
I haven't played with the plugin feature yet, but some things stand out to me about your code and I wonder if it is correct or not. Is there a difference in using go build vs go run, in the same way as you can get bad behaviour using go run with more complex apps? Have you tried moving those plug

Re: [go-nuts] plugin - How to open and lookup for interface implementation

2016-11-06 Thread Mateusz Dymiński
Does it mean that I can't load the two different plugins ? I know that I can't load the same plugin twice, but I thought that I can load two different plugins. To be precise I was thinking about the MapReduce implementation where the client might build the go program which can be loaded as plu

Re: [go-nuts] plugin - How to open and lookup for interface implementation

2016-11-05 Thread Tamás Gulácsi
AFAIK it's a design decision that a plugin cannot be loaded twice. Protect it with a sync.Once, if you can't avoid calling the loader twice. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails

Re: [go-nuts] plugin - How to open and lookup for interface implementation

2016-11-05 Thread Mateusz Dymiński
I started to play with this new plugin feature and I got some problems when I tried to load two different plugins one by one. If I have first plugin as it was describe in the original post and new one: *Interface:* package processor type Processor interface { Process(text string) } *And implem

Re: [go-nuts] plugin - How to open and lookup for interface implementation

2016-11-03 Thread Mateusz Dymiński
A, thanks a lot for your help and sorry for trivial question. To test the type assertion I should use following code: printerImpl, ok := p.(*printer.Printer) if !ok { panic("wrong type") } (*printerImpl).Print("test") I was trying to call the 'Print' func as *printerImpl.Print("test") no

Re: [go-nuts] plugin - How to open and lookup for interface implementation

2016-11-03 Thread David Crawshaw
The Lookup method is returning a pointer to the symbol (That way the program can modify the value of Impl through the plugin.) I believe you can write: printerImpl := *p.(*printer.Printer) On Thu, Nov 3, 2016 at 9:44 AM, Ian Lance Taylor wrote: > [ +crawshaw ] > > On Thu, Nov 3, 2016 at 12:51 A

Re: [go-nuts] plugin - How to open and lookup for interface implementation

2016-11-03 Thread Ian Lance Taylor
[ +crawshaw ] On Thu, Nov 3, 2016 at 12:51 AM, Mateusz Dymiński wrote: > Hi, > > I am trying to load dynamically implementation of particular interface. I've > created the example in following repo: > https://github.com/mateuszdyminski/go-plugin > > I have interface - let's call it Printer: > pac

[go-nuts] plugin - How to open and lookup for interface implementation

2016-11-03 Thread Mateusz Dymiński
Hi, I am trying to load dynamically implementation of particular interface. I've created the example in following repo: https://github.com/mateuszdyminski/go-plugin I have interface - let's call it Printer: package printer type Printer interface { Print(text string) } And implementation of t