Description
https://go.dev/doc/comment#doclinks currently says:
Doc links are links of the form “[Name1]” or “[Name1.Name2]” to refer to exported identifiers in the current package
but it is somewhat ambiguous about whether the [Name1.Name2]
form can refer to struct fields or only methods.
In practice, people do seem to intuitively expect references to struct fields to work; for example, this comment on types.Package.GoVersion
(written by @rsc) refers to the go/ast.File.GoVersion
struct field, and pkg.go.dev
appears to render that reference correctly:
However, similar references within the same package are not rendered as links. For example, the reference to [CheckedFiles.SizeError]
from zip.CheckedFiles.Err
is currently rendered as plain text:
go/doc.Parser
uses different functions to resolve intra- vs. inter-package references: it appears that the LookupPackage
hook being used by pkgsite
does resolve struct fields, whereas the LookupSym
hook does not.