title: Go - How to unmarshal XML into container struct with a slice
body: <p>I have an XML structure that essentially, includes an array of nodes that should deserialize into a slice of a simple go struct but it's not working. Here's the code I'm working with (the comments show what I expect):</p>
  
  <pre><code>package main
  
  import "fmt"
  import "encoding/xml"
  
  func main() {
      c := Conversation{}
      xml.Unmarshal(raw, &amp;c)
      fmt.Println(len(c.Dialog))    // expecting 2, not 0
      fmt.Println(c.Dialog[0].Text) // expecting "Hi", not a panic
  }
  
  var raw = []byte(`&lt;conversation&gt;
      &lt;message&gt;
          &lt;text&gt;Hi&lt;/text&gt;
      &lt;/message&gt;
      &lt;message&gt;
          &lt;text&gt;Bye&lt;/text&gt;
      &lt;/message&gt;
  &lt;/conversation&gt;`)
  
  type Conversation struct {
      Dialog []Message `xml:"conversation"`
  }
  
  type Message struct {
      XMLName xml.Name `xml:"message"`
      Text    string   `xml:"text"`
  }
  </code></pre>
  
  <p>Why isn't this working?</p>
  
  <p>Playground: <a href="http://play.golang.org/p/a_d-nhcfoP" rel="nofollow">http://play.golang.org/p/a_d-nhcfoP</a></p>