title: Convert []uint32 to []byte and vice versa in golang
body: <p>What's the most efficient way (in performance) to convert <code>[]uint32</code> to and from <code>[]byte</code> in Golang?</p>
  
  <p>for example:</p>
  
  <pre><code>func main() {
     source := []uint32{1,2,3}
     dest := make([]byte, 4 * len(source))
     // source to dest
     // ?
     check := len(dest)/4
     // dest to check
     // ?
  }
  </code></pre>
  
  <p>I have a <a href="http://play.golang.org/p/BBWElfj3Jq" rel="noreferrer">solution</a> but it consist div, mod, and multiply</p>
  
  <pre><code>package main
  import (
      "fmt"
  )
  func main() {
      source := []uint32{1,2,3}
      dest := make([]byte, 4*len(source))
      fmt.Println(source)
      for start, v := range source {
         dest[start*4+0] = byte(v % 256)
         dest[start*4+1] = byte(v / 256 % 256)
         dest[start*4+2] = byte(v / 256 / 256 % 256)
         dest[start*4+3] = byte(v / 256/ 256/ 256% 256)
      }
      fmt.Println(dest)
      check := make([]uint32,cap(dest)/4)
      for start := 0; start&lt;len(check); start++ {
         check[start] = uint32(dest[start*4+0]) + uint32(dest[start*4+1]) * 256 + uint32(dest[start*4+2]) * 256 * 256 + uint32(dest[start*4+3]) * 256 * 256 * 256
      }  
      fmt.Println(check)
  }
  </code></pre>