title: How to get the value type of a pointer through an interface?
body: <p>This <a href="http://play.golang.org/p/bXPV58DGF4" rel="noreferrer">playground</a> illustrates my question.</p>
  
  <p>Basically I have a function that accepts an empty interface as argument.  I want to pass anything in and print information on the types and values.  </p>
  
  <p>It works as expected except when I pass a pointer to a custom type (in my example, of underlying struct type).  I am not entirely sure how the reflection model is structured at that point.  Since the function signature specifies an <code>interface{}</code> argument when I call <code>reflect.Indirect(v).Kind()</code> it naturally returns <code>interface</code> but I want to know the type when the function is called.</p>
  
  <p>Below is the same code from playground:</p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "reflect"
  )
  
  func main() {
      var s interface{}
      s = CustomStruct{}
  
      PrintReflectionInfo(s)
      PrintReflectionInfo(&amp;s)
  }
  
  type CustomStruct struct {}
  
  func PrintReflectionInfo(v interface{}) {
      // expect CustomStruct if non pointer
      fmt.Println("Actual type is:", reflect.TypeOf(v))
  
      // expect struct if non pointer
      fmt.Println("Value type is:", reflect.ValueOf(v).Kind())
  
      if reflect.ValueOf(v).Kind() == reflect.Ptr {
          // expect: CustomStruct
          fmt.Println("Indirect type is:", reflect.Indirect(reflect.ValueOf(v)).Kind()) // prints interface
  
          // expect: struct
          fmt.Println("Indirect value type is:", reflect.Indirect(reflect.ValueOf(v)).Kind()) // prints interface
      }
  
      fmt.Println("")
  }
  </code></pre>