title: Convert array to slice in Go
body: <p>This seems like it would be a fairly common thing and abundant examples across the interwebs, but I can't seem to find an example of how to convert an <code>[32]byte</code> to <code>[]byte</code>.</p>
  
  <p>I have a function that I call from an external lib that returns an array</p>
  
  <pre><code>func Foo() [32]byte {...}
  </code></pre>
  
  <p>I then need to pass that result to a different function for further processing.</p>
  
  <pre><code>func Bar(b []byte) { ... }
  </code></pre>
  
  <p>Unforunately, if I try to call</p>
  
  <pre><code>d := Foo()
  Bar(d)
  </code></pre>
  
  <p>I get</p>
  
  <pre><code>cannot convert d (type [32]byte) to type []byte
  </code></pre>
  
  <p>Doing</p>
  
  <pre><code>[]byte(d)
  </code></pre>
  
  <p>isn't much better.  How do I do this, especially without creating a copy of the data (seems silly to copy this data when all I'm doing is passing it along).</p>