Debian Codegraph @

go/analysis/passes/unusedwrite/testdata/src/importsunsafe/i.go

raw symbols SCIP
1 package importsunsafe
2
3 import "unsafe"
4
5 type S struct {
6 F, G int
7 }
8
9 func _() {
10 var s S
11 s.F = 1
12 // This write to G is used below, because &s.F allows access to all of s, but
13 // the analyzer would naively report it as unused. For this reason, we
14 // silence the analysis if unsafe is imported.
15 s.G = 2
16
17 ptr := unsafe.Pointer(&s.F)
18 t := (*S)(ptr)
19 println(t.G)
20 }