github.com/telepresenceio/telepresence/v2@v2.20.0-pro.6.0.20240517030216-236ea954e789/pkg/slice/csv.go (about) 1 package slice 2 3 import ( 4 "bytes" 5 "encoding/csv" 6 "strings" 7 ) 8 9 // AsCSV returns the string slice encoded by a csv.NewWriter. 10 func AsCSV(vs []string) string { 11 b := &bytes.Buffer{} 12 w := csv.NewWriter(b) 13 if err := w.Write(vs); err != nil { 14 // The underlying bytes.Buffer should never error. 15 panic(err) 16 } 17 w.Flush() 18 return strings.TrimSuffix(b.String(), "\n") 19 }