Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

So subtyping automatically happens for all members of a struct? I'm not sure I like that but I guess I'd have to see how well it works in practice.


No, it only happens if you embed the type, a.i. the member is anonymous.

http://golang.org/doc/effective_go.html#embedding

http://golang.org/ref/spec#Struct_types

Note that there's also interface embedding which is a different thing.


Ah, that makes a lot more sense. Thank you for explaining.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: