title: Go interfaces: static vs dynamic binding
body: <p>Go uses both dynamic and static binding. From my understanding, if you need to use a type assertion then it's dynamic. I want to validate my assumptions.</p>
  
  <pre><code>type Xer interface { 
    X()
  }
  
  type XYer interface {
    Xer
    Y()
  }
  
  type Foo struct{}
  func (Foo) X() { println("Foo#X()") }
  func (Foo) Y() { println("Foo#Y()") }
  </code></pre>
  
  <p><strong>Assumptions:</strong></p>
  
  <pre><code>foo := Foo{}
  
  // static: Foo -&gt; XYer
  var xy XYer = foo
  
  // static: XYer -&gt; Xer
  var x Xer = xy
  
  // static: Xer -&gt; interface{}
  var empty interface{} = x
  
  // dynamic: interface{} -&gt; XYer
  xy2 := empty.(XYer)
  
  // dynamic: XYer -&gt; Foo
  foo2 := xy2.(Foo)
  </code></pre>
  
  <p>So when converting from <code>type A</code> -> <code>interface B</code>, if <code>A</code> satisfies <code>B</code> then you don't need an assertion and the itable can be generated at compile time. What about a case where you use an assertion where it's not needed:</p>
  
  <pre><code>var x Xer = Foo{}
  empty := x.(interface{})
  </code></pre>
  
  <p>what happens in this case? If someone could clarify this for me that would great.</p>