Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
DeedleFake opened this issue Jul 3, 2020 · 0 comments
Open

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

DeedleFake opened this issue Jul 3, 2020 · 0 comments
Labels
NeedsInvestigation
Milestone

Comments

@DeedleFake
Copy link

@DeedleFake DeedleFake commented Jul 3, 2020

$ 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.

@agnivade agnivade changed the title go/doc: package search inconsistent with methods or fields cmd/doc: package search inconsistent with methods or fields Jul 3, 2020
@agnivade agnivade added the NeedsInvestigation label Jul 3, 2020
@agnivade agnivade added this to the Backlog milestone Jul 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation
Projects
None yet
Development

No branches or pull requests

2 participants