Re: [go-nuts] json encoding & decoding interface types

2018-02-20 Thread Burak Serdar
On Mon, Feb 19, 2018 at 5:14 PM, Doğan Kurt wrote: > Hi Burak, > > The example objects are very simplified. In real code, there are many more > object types and some of them looks exactly same. For instance; > > type chromeHomepage struct { > Url string > File string > }

Re: [go-nuts] json encoding & decoding interface types

2018-02-19 Thread Krzysztof Kowalczyk
The core issue seems to be that that round-tripping via json looses information i.e. type of serialized record. You solved it by embedding type as field of the record, which works. You could embed type implicitly. One way to do it is to use a separate file for each type. The type is

Re: [go-nuts] json encoding & decoding interface types

2018-02-19 Thread Doğan Kurt
Hi Burak, The example objects are very simplified. In real code, there are many more object types and some of them looks exactly same. For instance; type chromeHomepage struct { Url string File string } type firefoxHomepage struct { Url string File string } They look exactly same in the

Re: [go-nuts] json encoding & decoding interface types

2018-02-19 Thread Burak Serdar
On Mon, Feb 19, 2018 at 4:45 PM, Doğan Kurt wrote: > Hi great Go community. Sorry it's a long question, but i would really > appreciate some guidance. > > > > > > Let's say i have two different objects, browser and executable that > implement

[go-nuts] json encoding & decoding interface types

2018-02-19 Thread Doğan Kurt
Hi great Go community. Sorry it's a long question, but i would really appreciate some guidance. Let's say i have two different objects, browser and executable that implement ScanCleaner interface. type ScanCleaner interface { scan() clean() } type browser struct { Name