github.com/v2fly/tools@v0.100.0/internal/lsp/testdata/godef/a/a.go (about) 1 // Package a is a package for testing go to definition. 2 package a //@mark(aPackage, "a "),hover("a ", aPackage) 3 4 import ( 5 "fmt" 6 "go/types" 7 "sync" 8 ) 9 10 var ( 11 // x is a variable. 12 x string //@x,hover("x", x) 13 ) 14 15 // Constant block. When I hover on h, I should see this comment. 16 const ( 17 // When I hover on g, I should see this comment. 18 g = 1 //@g,hover("g", g) 19 20 h = 2 //@h,hover("h", h) 21 ) 22 23 // z is a variable too. 24 var z string //@z,hover("z", z) 25 26 type A string //@mark(AString, "A") 27 28 func AStuff() { //@AStuff 29 x := 5 30 Random2(x) //@godef("dom2", Random2) 31 Random() //@godef("()", Random) 32 33 var err error //@err 34 fmt.Printf("%v", err) //@godef("err", err) 35 36 var y string //@string,hover("string", string) 37 _ = make([]int, 0) //@make,hover("make", make) 38 39 var mu sync.Mutex 40 mu.Lock() //@Lock,hover("Lock", Lock) 41 42 var typ *types.Named //@mark(typesImport, "types"),hover("types", typesImport) 43 typ.Obj().Name() //@Name,hover("Name", Name) 44 } 45 46 type A struct { 47 } 48 49 func (_ A) Hi() {} //@mark(AHi, "Hi") 50 51 type S struct { 52 Field int //@mark(AField, "Field") 53 R // embed a struct 54 H // embed an interface 55 } 56 57 type R struct { 58 Field2 int //@mark(AField2, "Field2") 59 } 60 61 func (_ R) Hey() {} //@mark(AHey, "Hey") 62 63 type H interface { 64 Goodbye() //@mark(AGoodbye, "Goodbye") 65 } 66 67 type I interface { 68 B() //@mark(AB, "B") 69 J 70 } 71 72 type J interface { 73 Hello() //@mark(AHello, "Hello") 74 } 75 76 func _() { 77 // 1st type declaration block 78 type ( 79 a struct { //@mark(declBlockA, "a"),hover("a", declBlockA) 80 x string 81 } 82 ) 83 84 // 2nd type declaration block 85 type ( 86 // b has a comment 87 b struct{} //@mark(declBlockB, "b"),hover("b", declBlockB) 88 ) 89 90 // 3rd type declaration block 91 type ( 92 // c is a struct 93 c struct { //@mark(declBlockC, "c"),hover("c", declBlockC) 94 f string 95 } 96 97 d string //@mark(declBlockD, "d"),hover("d", declBlockD) 98 ) 99 100 type ( 101 e struct { //@mark(declBlockE, "e"),hover("e", declBlockE) 102 f float64 103 } // e has a comment 104 ) 105 }