Development Blog‎ > ‎

Casting a Go uint32 to a byte array

posted Sep 18, 2012, 7:52 AM by Stan Steel
Why I am keeping this information is a mystery.

func main() {
  var i uint32 = 0x12345678;
  x := (*[4]byte)(unsafe.Pointer(&i))
  for _, xn := range *x {
    fmt.Printf("%x\n", xn)
  } 
}
Comments