title: Access struct property by name
body: <p>Here is a simple go program that is not working :</p>
  
  <pre><code>package main
  import "fmt"
  
  type Vertex struct {
      X int
      Y int
  }
  
  func main() {
      v := Vertex{1, 2}
      fmt.Println(getProperty(&amp;v, "X"))
  }
  
  func getProperty(v *Vertex, property string) (string) {
      return v[property]
  }
  </code></pre>
  
  <p>Error:</p>
  
  <blockquote>
    <p>prog.go:18: invalid operation: v[property] (index of type *Vertex)</p>
  </blockquote>
  
  <p>What I want is to access the Vertex X property using its name. If I do <code>v.X</code> it works, but <code>v["X"]</code> doesn't. </p>
  
  <p>Can someone tell me how to make this work ?</p>