github.com/april1989/origin-go-tools@v0.0.32/cmd/guru/testdata/src/reflection/main.go (about) 1 package main 2 3 // This is a test of 'pointsto', but we split it into a separate file 4 // so that pointsto.go doesn't have to import "reflect" each time. 5 6 import "reflect" 7 8 var a int 9 var b bool 10 11 func main() { 12 m := make(map[*int]*bool) 13 m[&a] = &b 14 15 mrv := reflect.ValueOf(m) 16 if a > 0 { 17 mrv = reflect.ValueOf(&b) 18 } 19 if a > 0 { 20 mrv = reflect.ValueOf(&a) 21 } 22 23 _ = mrv // @pointsto mrv "mrv" 24 p1 := mrv.Interface() // @pointsto p1 "p1" 25 p2 := mrv.MapKeys() // @pointsto p2 "p2" 26 p3 := p2[0] // @pointsto p3 "p3" 27 p4 := reflect.TypeOf(p1) // @pointsto p4 "p4" 28 29 _, _, _, _ = p1, p2, p3, p4 30 }