title: Go: How to get length of slice in function?
body: <p>I've got a function to which I want to feed different kinds of slices after which I want to loop over them and print their contents. The following code works:</p>
  
  <pre><code>func plot(data interface{}){
      fmt.Println(data)
      //fmt.Println(len(data))
  }
  
  func main() {
      l := []int{1, 4, 3}
      plot(l)
  }
  </code></pre>
  
  <p>But when I uncomment the line in which I print the length of the slice, I get an error saying <code>invalid argument data (type interface {}) for len</code>.</p>
  
  <p>Any idea how I would be able to get the length of the slice so that I can loop over it?</p>