Debian Codegraph @

_test/unsafe6.go

raw symbols SCIP
1 package main
2
3 import (
4 "fmt"
5 "unsafe"
6 )
7
8 type S struct {
9 X int
10 Y int
11 Z int
12 }
13
14 func main() {
15 x := S{Z: 5}
16 ptr := unsafe.Pointer(&x)
17 offset := int(unsafe.Offsetof(x.Z))
18 p := unsafe.Add(ptr, offset)
19
20 i := *(*int)(p)
21
22 fmt.Println(i)
23 }
24
25 // Output:
26 // 5