[go-nuts] Re: how to reuse getters and setters of two different versions of struct ? [interface{}/generics]

2018-05-25 Thread anilkuncham
Thank you Alex for your quick reply. I figured it out. Using Interfaces is the right way to solve this. On Friday, 25 May 2018 12:08:01 UTC-7, alex@gmail.com wrote: > > This is what interfaces are for. > > You have: > type GetKeyer interface { > GetKey1() string > GetKey2() string >

[go-nuts] how to reuse getters and setters of two different versions of struct ? [interface{}/generics]

2018-05-25 Thread anilkuncham
Hi, I have a use case where there are two different versions of struct. The problem is when the model is retrieved from database, it can be of either version. Both structs have same getters implemented. This is what the code looks like. type structA { Key1 string Key2string } f