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 implementation of the methods for the struct instance, I write code to send interface name, method name and parameters to the server via my own protocol (e.g HTTP). Then it also receives and returns results to the place where we call methods. After we have such a library, we can use it with any interfaces and any methods, client side and server side will talk each other in our own protocol. You can encrypt data, compress data and do whatever with the data before you transfer it. Programers in client side just need to know which interface they want to use and they just use the library "servicefactory" to create a struct instance and use it to talk to the server. Before that, they must specify the IP to tell where the server is. I have successfully implemented the idea in Java and used it in my system with hundreds of interfaces. I wonder why I cannot do it in Go easily as what I did with Java. Regards, Dat. On Wed, Jun 21, 2017 at 6:00 AM, Ian Lance Taylor <i...@golang.org> wrote: > On Mon, Jun 19, 2017 at 8:38 PM, Dat Huynh <audathu...@gmail.com> 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 <audat...@gmail.com> wrote: > >> > Why do you need this feature? > > > > > > I have already answered the question in my email replying Lutz Horn. > > Thanks. Unfortunately, I don't understand your answer. You still > have to write the methods somewhere. reflect.MakeStruct is not going > to write the methods for you. And once you write the methods, you > have a type that implements the interface that you want. > > 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 golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.