title: Scan error: sql: Scan error on column index 11: destination not a pointer
body: <p>I understand what the issue is, I am not providing a pointer address when I am trying to scan the fields from my database call - however in this situation I am not quite sure how to work around it.</p>
  
  <p>I have a struct that looks like this:</p>
  
  <pre><code>type ItemsRequest struct {
      Sku      string `json:"sku"`
      Name     string `json:"name"`
      Barcode  string `json:"barcode,omitempty"`
      Category struct {
          ID               string        `json:"id,omitempty"`
          Name             string        `json:"name,omitempty"`
          Subcategories    []interface{} `json:"subcategories,omitempty"`
          CategoryPosition int           `json:"categoryPosition,omitempty"`
          ResourceURI      string        `json:"resource_uri,omitempty"`
      } `json:"category,omitempty"`
      CategoryPosition int               `json:"categoryPosition,omitempty"`
      LongDesc         string            `json:"longDesc,omitempty"`
      MinQty           int               `json:"minQty,omitempty"`
      MultQty          int               `json:"multQty,omitempty"`
      UnitPrice        string            `json:"unitPrice,omitempty"`
      ImageURLs        []string          `json:"imageURLs,omitempty"`
      Variants         []interface{}     `json:"variants,omitempty"`
      AdditionalPrices map[string]string `json:"additionalPrices,omitempty"`
      audtdatetime     int
  }
  </code></pre>
  
  <p>The <code>AdditionalPrices</code> field is meant to represent an object of values, e.g:</p>
  
  <pre><code>{
      'UK': "12.34",
      'AU': "14.00"
  }
  </code></pre>
  
  <p>As such, I'm fairly confident that the <code>map[string]string</code> type for the field is correct...</p>
  
  <p>I am retrieving data to populate this struct from my database and then trying to scan the results into an instance of this struct. In my query, I have a predefined number of columns for which I want to populate <code>AdditionalPrices</code> with.</p>
  
  <p>As such I started off with this:</p>
  
  <pre><code>func getItemsFromDB() []*ItemsRequest {
      rows, err := bcdataDBConnection.Query(`
          SELECT  *
          FROM    vProducts
          WHERE   max_audit_date_time &gt; @AuditTime
      `, sql.Named("AUDITTIME", 2016101412000000))
  
      if err != nil {
          log.Fatal("There was an issue with the query for items: ", err)
      }
  
      defer rows.Close()
  
      var items []*ItemsRequest
  
      for rows.Next() {
          var item = &amp;ItemsRequest{}
          err := rows.Scan(
              &amp;item.Sku,
              &amp;item.Name,
              &amp;item.Category.ID,
              &amp;item.Category.Name,
              &amp;item.Category.CategoryPosition,
              &amp;item.LongDesc,
              &amp;item.Barcode,
              &amp;item.UnitPrice,
              &amp;item.MinQty,
              &amp;item.MultQty,
              &amp;item.CategoryPosition,
              &amp;item.AdditionalPrices["NZBASE"],
              &amp;item.AdditionalPrices["NZWWW"],
              &amp;item.AdditionalPrices["MMCMFR"],
              &amp;item.AdditionalPrices["MMBASE"],
              &amp;item.AdditionalPrices["AUBASE"],
              &amp;item.AdditionalPrices["MMCMAU"],
              &amp;item.AdditionalPrices["AUDSA"],
              &amp;item.AdditionalPrices["AUDVIC"],
              &amp;item.AdditionalPrices["AUDWWW"],
              &amp;item.audtdatetime,
          )
          if err != nil {
              log.Fatal("Scan error: ", err)
          }
  
          items = append(items, item)
      }
  
      return items
  }
  </code></pre>
  
  <p>However this didn't appear to be correct syntax and so I changed it to:</p>
  
  <pre><code>func getItemsFromDB() []*ItemsRequest {
      rows, err := bcdataDBConnection.Query(`
          SELECT  *
          FROM    vHandshakeProducts
          WHERE   max_audit_date_time &gt; @AuditTime
      `, sql.Named("AUDITTIME", 2016101412000000))
  
      if err != nil {
          log.Fatal("There was an issue with the query for items: ", err)
      }
  
      defer rows.Close()
  
      var items []*ItemsRequest
  
      for rows.Next() {
          var item = &amp;ItemsRequest{}
          err := rows.Scan(
              &amp;item.Sku,
              &amp;item.Name,
              &amp;item.Category.ID,
              &amp;item.Category.Name,
              &amp;item.Category.CategoryPosition,
              &amp;item.LongDesc,
              &amp;item.Barcode,
              &amp;item.UnitPrice,
              &amp;item.MinQty,
              &amp;item.MultQty,
              &amp;item.CategoryPosition,
              item.AdditionalPrices["NZBASE"],
              item.AdditionalPrices["NZWWW"],
              item.AdditionalPrices["MMCMFR"],
              item.AdditionalPrices["MMBASE"],
              item.AdditionalPrices["AUBASE"],
              item.AdditionalPrices["MMCMAU"],
              item.AdditionalPrices["AUDSA"],
              item.AdditionalPrices["AUDVIC"],
              item.AdditionalPrices["AUDWWW"],
              &amp;item.audtdatetime,
          )
          if err != nil {
              log.Fatal("Scan error: ", err)
          }
  
          items = append(items, item)
      }
  
      return items
  }
  </code></pre>
  
  <p>Which my IDE likes more, however upon running it I get the error:</p>
  
  <blockquote>
    <p>2018/01/15 15:35:06 Scan error: sql: Scan error on column index 11: destination not a pointer</p>
  </blockquote>
  
  <p>So at this point, I'm not quite sure how to populate the values for <code>AdditionalPrices</code> from my database call.</p>
  
  <p>What do I need to do to populate the <code>AdditionalPrices</code> map with the values I get from the database?
  As per the keys in my code, I already know the map keys for which I would like to assign the values to.</p>