title: How to access a slice in struct in golang
body: <p>How can I access a slice defined inside the struct?</p>
  
  <pre><code>type Car struct {
      Year int
      Name string
      Type []int
  }
  </code></pre>
  
  <p>//Accessing "Type" array field as below causes error: array out of range.</p>
  
  <pre><code>Car.Type[0] = 12
  Car.Type[1] = 15
  Car.Type[2] = 11
  </code></pre>