title: Unmarshal CSV record into struct in Go
body: <p>The problem how to automatically deserialize/unmarshal record from CSV file into Go struct.</p>
  
  <p>For example, I have </p>
  
  <pre><code>type Test struct {
    Name string
    Surname string
    Age int
  }
  </code></pre>
  
  <p>And CSV file contains records</p>
  
  <pre><code>John;Smith;42
  Piter;Abel;50
  </code></pre>
  
  <p>Is there an easy way to unmarshal those records into struct except by using "encoding/csv" package for reading record and then doing something like</p>
  
  <pre><code>record, _ := reader.Read()
  test := Test{record[0],record[1],atoi(record[2])}
  </code></pre>