title: Golang: cast interface back to its original type
body: <p>I couldn't really find an answer to this, even though I looked up the Go documentation and examples. Is it possible to cast an interface back to its original type, dynamically? I know I can do something like this:</p>
  
  <pre><code>var myint int = 5
  var myinterface interface{}
  myinterface = myint
  recovered, _ := myinterface.(int)
  fmt.Println(recovered)
  </code></pre>
  
  <p>But here I know the type. I would like to have a map of unknown types (interfaces) and cast them back by using reflection, like this:</p>
  
  <pre><code>// put/pop writes/read to/from a map[string]interface{}
  var myint int = 5
  put("key" myint)
  pop("key", &amp;myint) // this should also work for objects or any other type
  </code></pre>
  
  <p>Like this it would by possible to store anything within a single map. The type will be handed in by the user when calling pop() (second argument is an interface). Is it possible to achive this using reflection?</p>