title: How to cast the address to a type and print it in GDB for Golang
body: <p>This is the piece of code:</p>
  
  <pre><code>package main
  
  import (
      "fmt"
  )
  
  type TestType struct {
      a int
      b int
  }
  
  func main() {
      var testType TestType = TestType{1, 2}
      fmt.Println(testType)
  }
  </code></pre>
  
  <p>And this is the gdb debug output:</p>
  
  <pre><code>(gdb) r
  Starting program: /home/bzhang/common/src/go/src/test/testBinary 
  
  Breakpoint 1, main.main () at /home/bzhang/common/src/go/src/test/main.go:14
  14              fmt.Println(testType)
  (gdb) p testType
  $1 = {a = 1, b = 2}
  (gdb) p &amp;testType
  $2 = (main.TestType *) 0xc820059ee8
  (gdb) p ('main.TestType'*) 0xc820059ee8
  A syntax error in expression, near `) 0xc820059ee8'.
  (gdb) p ('TestType'*) 0xc820059ee8     
  A syntax error in expression, near `) 0xc820059ee8'.
  (gdb) whatis testType
  type = main.TestType
  (gdb) 
  </code></pre>
  
  <p>Of course I know that I can print testType directly. But if it is a local variable, sometimes its value can not be printed out directly, and only its address is available. So I want to print its value with the indication of its type. But it seems not work correctly.
  Appreciate for your help!</p>