title: When to use []byte or string in Go?
body: <p>Frequently in writing Go applications, I find myself with the choice to use <code>[]byte</code> or <code>string</code>. Apart from the obvious mutability of <code>[]byte</code>, how do I decide which one to use?</p>
  
  <p>I have several use cases for examples:</p>
  
  <ol>
  <li>A function returns a new <code>[]byte</code>. Since the slice capacity is fixed, what reason is there to not return a string?</li>
  <li><code>[]byte</code> are not printed as nicely as <code>string</code> by default, so I often find myself casting to <code>string</code> for logging purposes. Should it always have been a <code>string</code>?</li>
  <li>When prepending <code>[]byte</code>, a new underlying array is always created. If the data to prepend is constant, why should this not be a <code>string</code>?</li>
  </ol>