title: How to add a struct to an array of structs in Go
body: <p>In golang I'm trying to make an array of messages, and the ability to easily add a new "object" to the array.</p>
  
  <pre><code>type Message struct {
      Name string
      Content string
  }
  
  var Messages = []Message{
      {
          Name: "Alice",
          Content: "Hello Universe",
      },{
          Name: "Bob",
          Content: "Hello World",
      },
  }
  
  func addMessage(m string) {
      var msg = new(Message)
      msg.Name = "Carol"
      msg.Content = m
      Messages = append(Messages, msg)
  }
  </code></pre>
  
  <p>When building I get an error that says: </p>
  
  <blockquote>
    <p>cannot use msg (type *Message) as type Message in append</p>
  </blockquote>
  
  <p>Why is <code>append()</code> not working (as I might expect from JavaScript's <code>array.concat()</code>), or is <code>new()</code> not working?</p>
  
  <p>Any other tips on how to improve this code are welcome since I'm obviously new to Go.</p>