title: unsafe.Pointer to []byte in Go
body: <p>I'm trying to write a screenshot function for my OpenGL project in Go, I'm using the OpenGL bindings found here:</p>
  
  <p><a href="https://github.com/go-gl/glow" rel="nofollow">https://github.com/go-gl/glow</a></p>
  
  <p>This is the code I use to make a screenshot, or well, it's what I'm working on:</p>
  
  <pre><code>    width, height := r.window.GetSize()
      pixels := make([]byte, 3*width*height)
  
      // Read the buffer into memory
      var buf unsafe.Pointer
      gl.PixelStorei(gl.UNPACK_ALIGNMENT, 1)
      gl.ReadPixels(0, 0, int32(width), int32(height), gl.RGB, gl.UNSIGNED_BYTE, buf)
      pixels = []byte(&amp;buf) // &lt;-- LINE 99
  </code></pre>
  
  <p>This triggers the following error during compile time:</p>
  
  <pre><code>video\renderer.go:99: cannot convert &amp;buf (type *unsafe.Pointer) to type []byte.
  </code></pre>
  
  <p>How do I convert <code>unsafe.Pointer</code> to a byte array?</p>