title: One-liner to transform []int into string
body: <p>Basically I have <code>[]int{1, 2, 3}</code>, I want a one-liner that transforms this into the string "1, 2, 3" (I need the delimiter to be custom, sometimes <code>.</code>, sometimes <code>,</code>, etc). Below is the best I could come up with. Searched online and did not seem to find a better answer.</p>
  
  <p>In most languages there is in-built support for this, e.g.:</p>
  
  <p>python:</p>
  
  <pre><code>&gt; A = [1, 2, 3]
  &gt; ", ".join([str(a) for a in A])
  '1, 2, 3'
  </code></pre>
  
  <p>go:</p>
  
  <pre><code>package main
  
  import (
      "bytes"
      "fmt"
      "strconv"
  )
  
  // Could not find a one-liner that does this :(.
  func arrayToString(A []int, delim string) string {
  
      var buffer bytes.Buffer
      for i := 0; i &lt; len(A); i++ {
          buffer.WriteString(strconv.Itoa(A[i]))
          if i != len(A)-1 {
              buffer.WriteString(delim)
          }
      }
  
      return buffer.String()
  }
  
  func main() {
      A := []int{1, 2, 3}
      fmt.Println(arrayToString(A, ", "))
  }
  </code></pre>
  
  <p>Surely there must be an utility buried into go that allows me to do this with a one-liner?</p>
  
  <p>I know that there is <code>strings.Join(A, ", ")</code>, but that only works if A is already []string.</p>