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: not printing package name in type query #31457

rsc opened this Issue Apr 13, 2019 · 1 comment


None yet
2 participants
Copy link

commented Apr 13, 2019

go doc big.NewInt tells me what package it is talking about:

$ go doc big.NewInt
package big // import "math/big"

func NewInt(x int64) *Int
    NewInt allocates and returns a new Int set to x.


but go doc big.Int does not:

$ go doc big.Int
type Int struct {
	// Has unexported fields.
    An Int represents a signed multi-precision integer. The zero value for an
    Int represents the value 0.

    Operations always take pointer arguments (*Int) rather than Int values, and
    each unique Int value requires its own unique *Int pointer. To "copy" an Int
    value, an existing (or newly allocated) Int must be set to a new value using
    the Int.Set method; shallow copies of Ints are not supported and may lead to

func NewInt(x int64) *Int
func (z *Int) Abs(x *Int) *Int
func (z *Int) Add(x, y *Int) *Int

It seems like the package line should be printed always, and there is just a bug in this code path.

/cc @robpike

@rsc rsc added this to the Go1.13 milestone Apr 13, 2019

@rsc rsc changed the title cmd/doc: not printing package name cmd/doc: not printing package name in type query Apr 13, 2019

@robpike robpike self-assigned this Apr 13, 2019


This comment has been minimized.

Copy link

commented Apr 13, 2019

There's inconsistency for sure; this one doesn't print the package either:

% go doc fmt.printf
func Printf(format string, a ...interface{}) (n int, err error)
    Printf formats according to a format specifier and writes to standard
    output. It returns the number of bytes written and any write error


Should the package always be printed? Maybe. Or maybe just if the arguments don't match the package name?

There's also this, which is annoying. If I run that command in my home directory, not in a module directory, I get a distracting message containing nothing mentioned on the command line:

bismarck=% go doc fmt.printf
warning: pattern "all" matched no module dependencies
func Printf(format string, a ...interface{}) (n int, err error)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.