title: How to make a slice from a mapset.Set?
body: <p>I'm reading Donovan's "The Go Programming Language" book and trying to implement an exercise which prints duplicate lines from several files and the files in which they occur:</p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "io/ioutil"
      "os"
      "strings"
  
      mapset "github.com/deckarep/golang-set"
  )
  
  func main() {
      counts := make(map[string]int)
      occurrences := make(map[string]mapset.Set)
      for _, filename := range os.Args[1:] {
          data, err := ioutil.ReadFile(filename)
          if err != nil {
              fmt.Fprintf(os.Stderr, "dup3: %v\n", err)
              continue
          }
          for _, line := range strings.Split(string(data), "\n") {
              counts[line]++
              occurrences[line].Add(filename)
          }
      }
      for line, n := range counts {
          if n &gt; 1 {
              fmt.Printf("%d\t%s\t%s\n", n, line, strings.Join(occurrences[line], ", "))
          }
      }
  }
  </code></pre>
  
  <p>To accomplish the exercise, I've used the <a href="https://godoc.org/github.com/deckarep/golang-set" rel="nofollow noreferrer">https://godoc.org/github.com/deckarep/golang-set</a> package. However, I'm not sure how to print out the elements of the set joined by a ", ". With this code, I get a</p>
  
  <pre><code>./hello.go:23:30: first argument to append must be slice; have interface { Add(interface {}) bool; Cardinality() int; CartesianProduct(mapset.Set) mapset.Set; Clear(); Clone() mapset.Set; Contains(...interface {}) bool; Difference(mapset.Set) mapset.Set; Each(func(interface {}) bool); Equal(mapset.Set) bool; Intersect(mapset.Set) mapset.Set; IsProperSubset(mapset.Set) bool; IsProperSuperset(mapset.Set) bool; IsSubset(mapset.Set) bool; IsSuperset(mapset.Set) bool; Iter() &lt;-chan interface {}; Iterator() *mapset.Iterator; Pop() interface {}; PowerSet() mapset.Set; Remove(interface {}); String() string; SymmetricDifference(mapset.Set) mapset.Set; ToSlice() []interface {}; Union(mapset.Set) mapset.Set }
  ./hello.go:28:64: cannot use occurrences[line] (type mapset.Set) as type []string in argument to strings.Join
  </code></pre>
  
  <p>I wasn't able to easily find out how to convert the <code>Set</code> to a slice though. Any idea how I might accomplish this?</p>