title: In Go, why is my JSON decoding not working here?
body: <p>I cannot get the standard library's <code>encoding/json</code> package to work for decoding JSON objects. Here's a minimal example:</p>
  
  <pre><code>b := []byte(`{"groups":[{"name":"foo"},{"name":"bar"}]}`)
  type Group struct{ name string }
  var contents struct {
      groups []Group
  }
  err := json.Unmarshal(b, &amp;contents)
  fmt.Printf("contents = %+v\nerr = %+v\n", contents, err)
  </code></pre>
  
  <p>This prints:</p>
  
  <pre><code>contents = {groups:[]}
  err = nil
  </code></pre>
  
  <p>But I expect:</p>
  
  <pre><code>contents = {groups:[{name:foo} {name:bar}]}
  </code></pre>
  
  <p>What am I doing wrong?</p>