golang.org/x/tools/gopls@v0.15.3/internal/test/marker/testdata/definition/cgo.txt (about) 1 This test is ported from the old marker tests. 2 It tests hover and definition for cgo declarations. 3 4 -- flags -- 5 -cgo 6 7 -- go.mod -- 8 module cgo.test 9 10 go 1.18 11 12 -- cgo/cgo.go -- 13 package cgo 14 15 /* 16 #include <stdio.h> 17 #include <stdlib.h> 18 19 void myprint(char* s) { 20 printf("%s\n", s); 21 } 22 */ 23 import "C" 24 25 import ( 26 "fmt" 27 "unsafe" 28 ) 29 30 func Example() { //@loc(cgoexample, "Example"), item(cgoexampleItem, "Example", "func()", "func") 31 fmt.Println() 32 cs := C.CString("Hello from stdio\n") 33 C.myprint(cs) 34 C.free(unsafe.Pointer(cs)) 35 } 36 37 func _() { 38 Example() //@hover("ample", "Example", hoverExample), def("ample", cgoexample), complete("ample", cgoexampleItem) 39 } 40 41 -- @hoverExample -- 42 ```go 43 func Example() 44 ``` 45 46 [`cgo.Example` on pkg.go.dev](https://pkg.go.dev/cgo.test/cgo#Example) 47 -- usecgo/usecgo.go -- 48 package cgoimport 49 50 import ( 51 "cgo.test/cgo" 52 ) 53 54 func _() { 55 cgo.Example() //@hover("ample", "Example", hoverImportedExample), def("ample", cgoexample), complete("ample", cgoexampleItem) 56 } 57 -- @hoverImportedExample -- 58 ```go 59 func cgo.Example() 60 ``` 61 62 [`cgo.Example` on pkg.go.dev](https://pkg.go.dev/cgo.test/cgo#Example)