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 empty slice, []

func main() {
        i := 10
        p := unsafe.Pointer(&i)
        intPtr := (*[]byte)(p)
        fmt.Println(*intPtr)
}

Can someone explain why its so ? thanks.

-Santhosh.



-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to