golang unsafe.Pointer
type animal struct {
name string
kind string
}
func main() {
lion := animal{name: "lion", kind: "mammal"}
//第一个成员
name := (*string)(unsafe.Pointer(&lion))
*name = "tiger"
fmt.Println(lion)
name1 := (*string)(unsafe.Pointer(uintptr(unsafe.Pointer(&lion)) + unsafe.Offsetof(lion.name)))
*name1 = "tiger1"
fmt.Println(lion)
kind := (*string)(unsafe.Pointer(uintptr(unsafe.Pointer(&lion)) + unsafe.Offsetof(lion.kind)))
*kind = "cat"
fmt.Println(lion)
}