kythe.io@v0.0.68-0.20240422202219-7225dbc01741/kythe/go/indexer/testdata/basic/writes.go (about) 1 // Package writes tests ref/writes edges 2 package writes 3 4 import "fmt" 5 6 type S struct { 7 //- @F defines/binding F 8 F int 9 10 //- @Nested defines/binding Nested 11 Nested *S 12 } 13 14 func f() { 15 //- @x defines/binding X 16 var x int 17 18 //- @x ref/writes X 19 //- @y defines/binding Y 20 x, y := 1, 2 21 22 //- @x ref X 23 //- @x ref/writes X 24 x += 42 25 26 //- @y ref Y 27 //- @y ref/writes Y 28 y++ 29 30 //- @#0i defines/binding I 31 //- @#1i ref I 32 //- @#2i ref/writes I 33 //- @#3i ref I 34 for i := 0; i < 10; i = i + 1 { 35 } 36 37 //- @z defines/binding Z 38 //- @Nested ref/writes Nested 39 //- !{ @Nested ref Nested } 40 z := S{Nested: &S{}} 41 //- @z ref Z 42 //- @F ref/writes F 43 z.F = 42 44 //- @z ref Z 45 //- @Nested ref Nested 46 //- @F ref/writes F 47 z.Nested.F = 52 48 49 //- @x ref X 50 //- @y ref Y 51 fmt.Println(x, y) 52 } 53 54 func g() any { 55 //- @val defines/binding Val 56 var val int 57 58 return map[int]bool{ 59 //- @val ref Val 60 //- !{ @val ref/writes Val } 61 val: true, 62 } 63 }