title: How to efficiently concatenate strings in go
body: <p>In Go, a <code>string</code> is a primitive type, which means it is read-only, and every manipulation of it will create a new string.</p>
  <p>So if I want to concatenate strings many times without knowing the length of the resulting string, what's the best way to do it?</p>
  <p>The naive way would be:</p>
  <pre><code>var s string
  for i := 0; i &lt; 1000; i++ {
      s += getShortStringFromSomewhere()
  }
  return s
  </code></pre>
  <p>but that does not seem very efficient.</p>