Unsafe的使用

//var i uint16 = 0xFFFE
//bs := (*[int(unsafe.Sizeof(i))]byte)(unsafe.Pointer(&i))
//fmt.Println(*bs)
//ii:=(*uint16)(unsafe.Pointer(&*bs))//指针强转
//fmt.Println(*ii)
/**结构体转BTYE 与BYTE与结构体直接的互转***/
//var strc = A{}
//strc.B = 100
//strc.C =200
//data := *(*[unsafe.Sizeof(strc)]byte)(unsafe.Pointer(&strc))
//fmt.Println(data)
//strc1:= *(*A)(unsafe.Pointer(&data))
//fmt.Println(strc1)

你可能感兴趣的:(Unsafe的使用)