title: Can we write a generic array/slice deduplication in go?
body: <p>Is there a way to write a generic array/slice deduplication in go, for <code>[]int</code> we can have something like (from <a href="http://rosettacode.org/wiki/Remove_duplicate_elements#Go" rel="nofollow">http://rosettacode.org/wiki/Remove_duplicate_elements#Go</a> ):        </p>
  
  <pre><code>func uniq(list []int) []int {
    unique_set := make(map[int] bool, len(list))
    for _, x := range list {
       unique_set[x] = true
     }
    result := make([]int, len(unique_set))
    i := 0
    for x := range unique_set {
       result[i] = x
      i++
    }
    return result
  }
  </code></pre>
  
  <p>But is there a way to extend it to support any array? with a signature like:    </p>
  
  <pre><code>func deduplicate(a []interface{}) []interface{}
  </code></pre>
  
  <p>I know that you can write that function with that signature, but then you can't actually use it on <code>[]int</code>, you need to create a <code>[]interface{}</code> put everything from the <code>[]int</code> into it, pass it to the function then get it back and put it into a <code>[]interface{}</code> and go through this new array and put everything in a new <code>[]int</code>.       </p>
  
  <p><strong>My question is,</strong> is there a better way to do this? </p>