[go-nuts] unsafe.Pointer to byte slice

2017-07-08 Thread Dave Cheney
An array is a vector of values in memory. A slice is a small struct that describes an array stored elsewhere in memory. https://blog.golang.org/go-slices-usage-and-internals -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from th

[go-nuts] unsafe.Pointer to byte slice

2017-07-08 Thread Santhosh Ram Manohar
hello, This piece of code prints [10 0 0 0] as expected.. func main() { i := 10 p := unsafe.Pointer(&i) intPtr := (*[4]byte)(p) fmt.Println(*intPtr) } But if I convert the unsafe.Pointer to pointer to a byte slice rather than an array of 4 bytes it prints an empt