title: Golang type assertion with pointers
body: <p>I've been working in an interface to use as a hierarchical tree. The idea is to aloud the concrete implementations to call <code>.Children()</code>, <code>.Father()</code> and a function to auto populate the hierarchy based on a slice of <code>{id, FatherId}</code> schema.</p>
  
  <p>I only need three different implementations of this interface, maybe it's more convenient to do the whole thing for each struct but I'm new to Go and decided to use this example to understand interfaces.</p>
  
  <p>I've come to an interface that looks something like this:</p>
  
  <pre><code>type Node interface{
      Equals(nodo *Node) bool
      AddChild(child *Node)
      SetFather(father *Node)
  
      Children() []Node
      Father() *Node
  }
  </code></pre>
  
  <p>So the idea is call a <code>Populate</code> function:</p>
  
  <pre><code>func Populate(plainNodes []Node, HierarchichalNodes *[]Node) {}
  </code></pre>
  
  <p>Plain nodes would be items defining the id of his father:</p>
  
  <pre><code>{id: "Animal", father: ""}
  {id: "Plant", father: ""}
  {id: "Mammals", father: "Animal"}
  </code></pre>
  
  <p>Hierarchical nodes would be the result:</p>
  
  <pre><code>Animal
  |__Mammals
  
  Plant
  </code></pre>
  
  <p>The problem I'm getting is when I try to implement the interface in a concrete struct, this case <code>"Category"</code>.</p>
  
  <pre><code>type Category struct{
      children []Category
      father Category
  }
  
  func (c Category) SetFather(node *Node) {
      v, ok = node.(*Category)
      c.father = v
  }
  </code></pre>
  
  <p>Notice that in <code>Category</code> I want to work with <code>Category</code> father and children, not with interface <code>Node</code>.</p>
  
  <p>I can't do the conversion, I get :</p>
  
  <pre><code>invalid type assertion: nodo.(*Category) (non-interface type *Node on left)
  </code></pre>
  
  <p>Any ideas?</p>