Skip to content

cmd/doc: package search inconsistent with methods or fields #40011

Description

@DeedleFake
$ go version
go version devel +5de90d33c8 Thu Jul 2 22:08:11 2020 +0000 linux/amd64

Running go doc rand, as expected, gives the documentation for crypto/rand, as it finds that one before math/rand:

package rand // import "crypto/rand"

Package rand implements a cryptographically secure random number generator.

var Reader io.Reader
func Int(rand io.Reader, max *big.Int) (n *big.Int, err error)
func Prime(rand io.Reader, bits int) (p *big.Int, err error)

Running go doc rand.rand, however, gives the documentation for math/rand.Rand, as it uses the lack of the symbol in crypto/rand to know that that's not the right package. So far so good:

package rand // import "math/rand"

type Rand struct {
        // Has unexported fields.
}
    A Rand is a source of random numbers.

func New(src Source) *Rand
func (r *Rand) ExpFloat64() float64
func (r *Rand) Float32() float32
func (r *Rand) Float64() float64
func (r *Rand) Int() int
func (r *Rand) Int31() int32
func (r *Rand) Int31n(n int32) int32
func (r *Rand) Int63() int64
func (r *Rand) Int63n(n int64) int64
func (r *Rand) Intn(n int) int
func (r *Rand) NormFloat64() float64
func (r *Rand) Perm(n int) []int
func (r *Rand) Read(p []byte) (n int, err error)
func (r *Rand) Seed(seed int64)
func (r *Rand) Shuffle(n int, swap func(i, j int))
func (r *Rand) Uint32() uint32
func (r *Rand) Uint64() uint64

However, running go doc rand.rand.int fails:

doc: symbol rand is not a type in package rand installed in "crypto/rand"
exit status 1

It seems like it doesn't actually search past the first package if there's a method specified. Manually specifying the package, such as go doc math/rand.rand.int, works as expected.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions