It would be easier to do:
type User struct {
Name string `json:"name"`
}
type PrivateUser struct {
User
Password string `json:"password"`
}
See https://play.golang.org/p/2VlGgRlrP1
On Wednesday, November 30, 2016 at 2:42:19 PM UTC+5:30, Mirco Zeiss wrote:
>
> Maybe I'll just wait for go 1.8
On Wednesday, November 23, 2016 at 8:21:23 PM UTC+5:30, Tong Sun wrote:
> I've tried to derive how to achieve a) implementation inheritance,
>> followed by b) type substitution and c) enabling dynamic dispatch as in
>> virtual functions in my blog post here:
>>
I've tried to derive how to achieve a) implementation inheritance, followed
by b) type substitution and c) enabling dynamic dispatch as in virtual
functions in my blog post
here: https://tech.t9i.in/2014/01/22/inheritance-semantics-in-go/
I also like the approach suggested by Sebastien Binet.