| 1 |
This test demonstrates some basic features of hover. |
| 2 |
|
| 3 |
One of those features is the display of per-file variation in |
| 4 |
configuration, including GODEBUG. We use panicnil from go1.21 as an |
| 5 |
arbitrary GODEBUG; if it goes away, pick another from |
| 6 |
https://go.dev/doc/godebug#history. |
| 7 |
|
| 8 |
-- settings.json -- |
| 9 |
{"analyses": {"unusedfunc": false}} |
| 10 |
|
| 11 |
-- flags -- |
| 12 |
-min_go_command=go1.21 |
| 13 |
|
| 14 |
-- go.mod -- |
| 15 |
module example.com |
| 16 |
|
| 17 |
go 1.18 |
| 18 |
|
| 19 |
-- a.go -- |
| 20 |
// package comment |
| 21 |
package aa //@hover("aa", "aa", aa) |
| 22 |
|
| 23 |
const abc = 0x2a //@hover("b", "abc", abc),hover(re"() =", "abc", abc) |
| 24 |
|
| 25 |
func _() { |
| 26 |
// hover over foo should include this comment |
| 27 |
foo := func() {} //@hover("foo", "foo", foo) |
| 28 |
|
| 29 |
// hover over buzz should include this comment |
| 30 |
buzz := 10 //@hover("buzz", "buzz", buzz) |
| 31 |
|
| 32 |
notbazz := 10 // hover over bazz should not include this comment |
| 33 |
bazz := 10 //@hover("bazz", "bazz", bazz) |
| 34 |
println(foo, buzz, bazz, notbazz) |
| 35 |
} |
| 36 |
|
| 37 |
// hover over bar should include this comment |
| 38 |
var bar = func() {} //@hover("bar", "bar", bar) |
| 39 |
|
| 40 |
-- @bar -- |
| 41 |
```go |
| 42 |
var bar func() |
| 43 |
``` |
| 44 |
|
| 45 |
--- |
| 46 |
|
| 47 |
hover over bar should include this comment |
| 48 |
-- @bazz -- |
| 49 |
```go |
| 50 |
var bazz int |
| 51 |
``` |
| 52 |
-- @buzz -- |
| 53 |
```go |
| 54 |
var buzz int |
| 55 |
``` |
| 56 |
|
| 57 |
--- |
| 58 |
|
| 59 |
hover over buzz should include this comment |
| 60 |
-- @foo -- |
| 61 |
```go |
| 62 |
var foo func() |
| 63 |
``` |
| 64 |
|
| 65 |
--- |
| 66 |
|
| 67 |
hover over foo should include this comment |
| 68 |
-- a2.go -- |
| 69 |
|
| 70 |
//go:build go1.21 |
| 71 |
|
| 72 |
package aa //@hover("aa", "aa", aa2) |
| 73 |
|
| 74 |
-- typeswitch.go -- |
| 75 |
package aa |
| 76 |
|
| 77 |
func _() { |
| 78 |
var y any |
| 79 |
switch x := y.(type) { //@hover("x", "x", x) |
| 80 |
case int: |
| 81 |
println(x) //@hover("x", "x", xint) |
| 82 |
} |
| 83 |
} |
| 84 |
-- cmd/main.go -- |
| 85 |
//go:debug panicnil=0 |
| 86 |
|
| 87 |
// Note that since GODEBUG shows only settings that differ from |
| 88 |
// the current toolchain, the output here depends on the toolchain used. |
| 89 |
package main //@hover("main", "main", main) |
| 90 |
|
| 91 |
func main() { |
| 92 |
} |
| 93 |
|
| 94 |
-- @abc -- |
| 95 |
```go |
| 96 |
const abc untyped int = 0x2a // 42 |
| 97 |
``` |
| 98 |
|
| 99 |
--- |
| 100 |
|
| 101 |
@hover("b", "abc", abc),hover(re"() =", "abc", abc) |
| 102 |
-- @x -- |
| 103 |
```go |
| 104 |
var x any |
| 105 |
``` |
| 106 |
-- @xint -- |
| 107 |
```go |
| 108 |
var x int |
| 109 |
``` |
| 110 |
-- @aa -- |
| 111 |
```go |
| 112 |
package aa |
| 113 |
``` |
| 114 |
|
| 115 |
--- |
| 116 |
|
| 117 |
package comment |
| 118 |
|
| 119 |
|
| 120 |
--- |
| 121 |
|
| 122 |
- Package path: example.com |
| 123 |
- Module: example.com |
| 124 |
- Language version: go1.18 |
| 125 |
-- @aa2 -- |
| 126 |
```go |
| 127 |
package aa |
| 128 |
``` |
| 129 |
|
| 130 |
--- |
| 131 |
|
| 132 |
package comment |
| 133 |
|
| 134 |
|
| 135 |
--- |
| 136 |
|
| 137 |
- Package path: example.com |
| 138 |
- Module: example.com |
| 139 |
- Language version (current file): go1.21 |
| 140 |
-- @main -- |
| 141 |
```go |
| 142 |
package main |
| 143 |
``` |
| 144 |
|
| 145 |
--- |
| 146 |
|
| 147 |
Note that since GODEBUG shows only settings that differ from the current toolchain, the output here depends on the toolchain used. |
| 148 |
|
| 149 |
|
| 150 |
--- |
| 151 |
|
| 152 |
- Package path: example.com/cmd |
| 153 |
- Module: example.com |
| 154 |
- Language version: go1.18 |