golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
122.95k stars 17.53k forks source link

go/doc/comment: Inconsistent documentation about comment.Parser.LookupPackage == nil #54201

Open ChrisHines opened 2 years ago

ChrisHines commented 2 years ago

What version of Go are you using (go version)?

$ go version
go version go1.19rc2 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What did you do?

$ go doc comment.Parser
[...]
        // Setting LookupPackage to nil is equivalent to setting it to
        // a function that always returns "", false.
        LookupPackage func(name string) (importPath string, ok bool)
[...]
$ go doc comment.DefaultLookupPackage
package comment // import "go/doc/comment"

func DefaultLookupPackage(name string) (importPath string, ok bool)
    DefaultLookupPackage is the default package lookup function, used when
    Parser.LookupPackage is nil. It recognizes names of the packages from the
    standard library with single-element import paths, such as math, which would
    otherwise be impossible to name.
[...]

What did you expect to see?

Consistent documentation.

What did you see instead?

Contradictory statements in the documentation for comment.Parser and comment.DefaultLookupPackage regarding the behavior when comment.Parser.LookupPackage == nil.

dmitshur commented 2 years ago

CC @rsc.