Methods, Interfaces and Embedded Types in Go

1 · · May 3, 2014, midnight
Introduction My business partner Ed asked me what would happen if a struct and an embedded field both implemented the same interface. We asked ourselves two questions: Would the compiler throw an error because we now had two implementations of the interface? If the compiler accepted the type declaration, how does the compiler determine which implementation to use for interface calls? We hacked out some code to answer the questions and then I dug into the specification....