title: Ensuring embedded structs implement interface without introducing ambiguity
body: <p>I'm trying to clean up my code base by doing a better job defining interfaces and using embedded structs to reuse functionality.  In my case I have many entity types that can be linked to various objects. I want to define interfaces that capture the requirements and structs that implement the interfaces which can then be embedded into the entities.</p>
  
  <pre><code>// All entities implement this interface
  type Entity interface {
    Identifier()
    Type()
  }
  
  // Interface for entities that can link Foos
  type FooLinker interface {
    LinkFoo()
  }
  
  type FooLinkerEntity struct {
    Foo []*Foo
  }
  
  func (f *FooLinkerEntity) LinkFoo() {
    // Issue: Need to access Identifier() and Type() here
    // but FooLinkerEntity doesn't implement Entity
  }
  
  // Interface for entities that can link Bars
  type BarLinker interface {
    LinkBar()
  }
  
  type BarLinkerEntity struct {
    Bar []*Bar
  }
  
  func (b *BarLinkerEntity) LinkBar() {
    // Issues: Need to access Identifier() and Type() here
    // but BarLinkerEntity doesn't implement Entity
  }
  </code></pre>
  
  <p>So my first thought was to have FooLinkerEntity and BarLinkerEntity just implement the Entity interface.</p>
  
  <pre><code>// Implementation of Entity interface
  type EntityModel struct {
      Id string
      Object string
  }
  
  func (e *EntityModel) Identifier() { return e.Id }
  func (e *EntityModel) Type() { return e.Type }
  
  type FooLinkerEntity struct {
    EntityModel
    Foo []*Foo
  }
  
  type BarLinkerEntity struct {
    EntityModel
    Bar []*Bar
  }
  </code></pre>
  
  <p>However, this ends up with an ambiguity error for any types that can link both Foos and Bars.</p>
  
  <pre><code>// Baz.Identifier() is ambiguous between EntityModel, FooLinkerEntity,
  // and BarLinkerEntity.
  type Baz struct {
      EntityModel
      FooLinkerEntity
      BarLinkerEntity
  }
  </code></pre>
  
  <p>What's the correct Go way to structure this type of code?  Do I just do a type assertion in <code>LinkFoo()</code> and <code>LinkBar()</code> to get to <code>Identifier()</code> and <code>Type()</code>? Is there any way to get this check at compile time instead of runtime?</p>