|
|
|
|
|
by bilbo-b-baggins
265 days ago
|
|
Normally you wouldn’t contrive to use embedded struct fields in this way. And you can’t have the same kind of composition with methods - it’s a compiler error: https://go.dev/play/p/r04tPta1xZo So the whole article is basically about using the language in a way you normally would ever do. |
|
https://go.dev/play/p/D3eFi9_can8
Conflicting functions at nested levels also compile:
https://go.dev/play/p/xXXDZCjQJOh
It's not about method vs field, it's about the nesting level of the conflicting identifier, if it's at the same level there's an error, if it's at different levels, the higher level hides the lower level identifier:
https://go.dev/doc/effective_go#embedding