title: golang, type int does not support indexing
body: <p>I have a trouble in a part of code. I'm writing on revel framework(to be clear). This is a Worker go routine, and I want it to do several things: </p>
  
  <ol>
  <li><p>switch the struct type of the stat variable, according to the
  source, that would come. I made a switch, but before the all other
  code would be correct, I don't really know if switch is written
  properly. </p></li>
  <li><p>I get cache for the date, and put it in new Work item.  </p></li>
  <li><p>I send Work to channel</p></li>
  </ol>
  
  <p>here is what I got by now:</p>
  
  <pre><code>func worker(in &lt;-chan Task, out chan &lt;- Work, wg *sync.WaitGroup) {
  
      for t := range in {
          for sourceName, charts := range t.Request.Charts {
  
              var stat interface{}
  
              switch sourceName {
              case "noagg":
                   stat = stat.([]NoaggModel)
              case "oracle":
                  stat = stat.([]OracleModel)
              default:
                  panic("Invalid type for Work model!")
              }
  
              w := Work{Name:"", Data:""}
  
              err := cache.Get(string(sourceName)+"_"+string(t.Date), &amp;stat);
  
              for chart := range charts{
                  w.Name = chart["name"]
  
                  if err == nil{
                      w.Data = countDataByName( stat, t.Request.Filters, string(chart["name"]))
                  }
                  out &lt;- w
              }
          }
      }
      wg.Done() // this worker is now done; let the WaitGroup know.
  }
  </code></pre>
  
  <p>But now I got error that <code>invalid operation: chart["name"] (type int does not support indexing)</code> </p>
  
  <p>But I have structs :</p>
  
  <pre><code>type Chart struct {
      Name string           `json:"name"`
      Type string           `json:"type"`
  }
  
  type Filter struct {
      DayStart string `json:"dayStart"`
      DayEnd string `json:"dayEnd"`
      TimePeriods interface{} `json:"timePeriods"`
      Lines []string `json:"lines"`
  }
  
  type Task struct {
      Date string
      Request ChartOptins
  }
  
  type Work struct {
      Name string
      Data interface{}
  }
  </code></pre>
  
  <p>How should I write in a better way the correct switch, if the type of struct for cache can be different, and why is my name adding is bad and call error?</p>