1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
This test checks that we correctly determine pkgsite links for various
identifiers.
We should only produce links that work, meaning the object is reachable via the
package's public API.
-- go.mod --
module mod.com
go 1.18
-- p.go --
package p
type E struct {
Embed int64
}
// T is in the package scope, and so should be linkable.
type T struct{ //@hover("T", "T", T)
// Only exported fields should be linkable
f int64 //@hover("f", "f", f)
F int64 //@hover("F", "F", F)
E
// TODO(rfindley): is the link here correct? It ignores N.
N struct {
// Nested fields should also be linkable.
Nested int64 //@hover("Nested", "Nested", Nested)
}
}
// M is an exported method, and so should be linkable.
func (T) M() {}
// m is not exported, and so should not be linkable.
func (T) m() {}
func _() {
var t T
// Embedded fields should be linkable.
_ = t.Embed //@hover("Embed", "Embed", Embed)
// Local variables should not be linkable, even if they are capitalized.
var X int64 //@hover("X", "X", X)
_ = X
// Local types should not be linkable, even if they are capitalized.
type Local struct { //@hover("Local", "Local", Local)
E
}
// But the embedded field should still be linkable.
var l Local
_ = l.Embed //@hover("Embed", "Embed", Embed)
}
-- @Embed --
```go
field Embed int64
```
[`(p.E).Embed` on pkg.go.dev](https://pkg.go.dev/mod.com#E.Embed)
-- @F --
```go
field F int64 // size=8, offset=8
```
@hover("F", "F", F)
[`(p.T).F` on pkg.go.dev](https://pkg.go.dev/mod.com#T.F)
-- @Local --
```go
type Local struct { // size=8
E
}
```
Local types should not be linkable, even if they are capitalized.
```go
// Embedded fields:
Embed int64 // through E
```
-- @Nested --
```go
field Nested int64 // size=8, offset=0
```
Nested fields should also be linkable.
-- @T --
```go
type T struct { // size=32 (0x20)
f int64 //@hover("f", "f", f)
F int64 //@hover("F", "F", F)
E
// TODO(rfindley): is the link here correct? It ignores N.
N struct {
// Nested fields should also be linkable.
Nested int64 //@hover("Nested", "Nested", Nested)
}
}
```
T is in the package scope, and so should be linkable.
```go
// Embedded fields:
Embed int64 // through E
```
```go
func (T) M()
func (T) m()
```
[`p.T` on pkg.go.dev](https://pkg.go.dev/mod.com#T)
-- @X --
```go
var X int64
```
Local variables should not be linkable, even if they are capitalized.
-- @f --
```go
field f int64 // size=8, offset=0
```
@hover("f", "f", f)
|