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)