Re: [go-nuts] Create methods for structs at runtime

2017-06-20 Thread Josh Humphries
This is a problem that is usually solved in Go with code generation. You would use a go:generate directive to generate implementations for an interface of interest. Something like java.lang.reflect.Proxy in Go would be very cool though. *Josh Humphries* jh...@bluegosling.com On Tue, Jun

Re: [go-nuts] Create methods for structs at runtime

2017-06-20 Thread Dat Huynh
Hi Ian, The struct instance I create for an interface will actually take the role of transport layer. I will not implement the real logic of the methods of the interface in client side. The real implementation for the logic of the methods will be implemented on the server side only. In the

Re: [go-nuts] Create methods for structs at runtime

2017-06-20 Thread Henrik Johansson
I think perhaps http://www.grpc.io/ can help if you want remoting but perhaps it will also give you too much bootstrap. tis 20 juni 2017 kl 22:00 skrev Ian Lance Taylor : > On Mon, Jun 19, 2017 at 8:38 PM, Dat Huynh wrote: > > > > On Tuesday, June 20, 2017

Re: [go-nuts] Create methods for structs at runtime

2017-06-20 Thread Ian Lance Taylor
On Mon, Jun 19, 2017 at 8:38 PM, Dat Huynh wrote: > > On Tuesday, June 20, 2017 at 4:07:46 AM UTC+10, Ian Lance Taylor wrote: >> >> On Sat, Jun 17, 2017 at 5:17 PM, Dat Huynh wrote: >> > Why do you need this feature? > > > I have already answered the

Re: [go-nuts] Create methods for structs at runtime

2017-06-19 Thread Dat Huynh
On Tuesday, June 20, 2017 at 4:07:46 AM UTC+10, Ian Lance Taylor wrote: > > On Sat, Jun 17, 2017 at 5:17 PM, Dat Huynh > wrote: > > Why do you need this feature? > I have already answered the question in my email replying Lutz Horn. Thank you very much. Sincerely, Dat.

Re: [go-nuts] Create methods for structs at runtime

2017-06-19 Thread Ian Lance Taylor
On Sat, Jun 17, 2017 at 5:17 PM, Dat Huynh wrote: > > Could you please let me know if there is any plan to fix the limitation? There is an intent to fix it, but I wouldn't go so far as to say there is a plan. As far as I know nobody is working on it. It's definitely a

Re: [go-nuts] Create methods for structs at runtime

2017-06-17 Thread Dat Huynh
Hi Ian, Could you please let me know if there is any plan to fix the limitation? Indeed, I am considering if it is worthwhile to rewrite my projects in Go. I have hundreds of interfaces in my Java apps and this feature will help me a lot. Thank you very much. Sincerely, Dat. On Wed, Jun

Re: [go-nuts] Create methods for structs at runtime

2017-06-14 Thread Kevin Malachowski
Maybe I'm missing something obvious, but why do you need to do this? Seems like some sort of remote dependency injection which requires you to serialize code from the server to the client. Why not just release a compiled client binary which has all of the implementations compiled in already,

Re: [go-nuts] Create methods for structs at runtime

2017-06-14 Thread Dat Huynh
Hi, What I want is to use interfaces to describe services for client side of my app. Then, I implement the services on the server side and allow client side to call the services via my pre-defined protocol (e.g HTTP, ...) In Java, I used the method newProxyInstance( ) of the class

Re: [go-nuts] Create methods for structs at runtime

2017-06-14 Thread Lutz Horn
Hi, Given an interface, how can I create a struct instance with the methods of the interface at runtime? What is your usecase for this? What problem are you trying to solve? Lutz -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To

Re: [go-nuts] Create methods for structs at runtime

2017-06-13 Thread Ian Lance Taylor
On Tue, Jun 13, 2017 at 9:27 PM, Dat Huynh wrote: > > I have a question about Go. > > Given an interface, how can I create a struct instance with the methods of > the interface at runtime? > > After reading the document of Go on the web page >

[go-nuts] Create methods for structs at runtime

2017-06-13 Thread Dat Huynh
Hi all, I have a question about Go. Given an interface, how can I create a struct instance with the methods of the interface at runtime? After reading the document of Go on the web page https://golang.org/pkg/reflect/#StructOf I see the below statement. "StructOf currently does not generate