unsafe经常用于与C程序交互
package unsafe
import (
"testing"
"unsafe"
)
func TestUnsafe(t *testing.T){
i := 10
f := *(*float64)(unsafe.Pointer(&i))
t.Logf("%T",f)
}
type MyInt int
func TestConvert(t *testing.T){
a := []int{1,2,3,4}
b := *(*[]MyInt)(unsafe.Pointer(&a))
t.Logf("%T",b)
}