title: General slice type in golang?
body: <p>I'm having some difficulties trying to extend slice types into a general type in Go. I have created a sample code to explain my problem. <a href="http://play.golang.org/p/LfeiVqiXR_" rel="nofollow">play ground version</a></p>
  
  <pre><code>package main
  
  import "fmt"
  
  type Sequencer interface {
      Mean() float64
  }
  
  type Sequence []int
  
  func (s Sequence) Mean() float64 {
      sum := 0.0
      for _, el := range s {
          sum += float64(el)
      }
      return sum / float64(len(s))
  }
  
  func main() {
      a := []int{1, 2, 3, 4}
      b := Sequence(a)
      fmt.Println(b.Mean())
      fmt.Println(b[:2].Mean())
      c := Sequencer(b)
      fmt.Println(c.Mean())
      fmt.Println(c[:2].Mean())
  }
  </code></pre>
  
  <p>Last line of the main() function returns an error saying that variables of type Sequencer cannot be sliced:</p>
  
  <blockquote>
    <p>cannot slice c (type Sequencer)</p>
  </blockquote>
  
  <p>Is there a way of defining a general type of slices (int, float64, string,...) without hiding the cool indexing capabilities of slices?</p>