123456789101112131415161718192021 |
- package main
- import (
- "fmt"
- "unsafe"
- )
- type object struct {
- f float64
- i int32
- }
- func main() {
- obj := &object{
- f: 1.0,
- i: 1,
- }
- f := (*float64)(unsafe.Pointer(obj))
- fmt.Println(*f) //1
- fmt.Println(unsafe.Pointer(obj) == unsafe.Pointer(f)) //true
- }
|