Either `go doc` confusion or `go mod tidy` confusion

63 views
Skip to first unread message

Kevin Chowski

unread,
Apr 22, 2026, 4:07:54 PM (2 days ago) Apr 22
to golang-nuts
Hey all,

I am a bit confused at what I'm seeing on my system, and I'm hoping someone can reveal what is happening.

I /meant/ to run `go doc http.Handle` but I typed `go doc http.Register` instead. The former works fine, whereas the latter gives me an unexpected error:

```
$ go doc http.Register
doc: go: updates to go.mod needed; to update it:
        go mod tidy
```

If I run `go mod tidy` it doesn't seem like anything happens: `go mod tidy -diff` shows nothing, and my local source control claims my `go.mod` wasn't modified after running `go mod tidy` directly.

Why doesn't `go doc` say something like "there is no Register in package http"? Is it trying to be smart but getting stuck somewhere else?

Nick White

unread,
Apr 22, 2026, 5:29:14 PM (2 days ago) Apr 22
to golan...@googlegroups.com
On Wed, Apr 22, 2026 at 01:07:54PM -0700, Kevin Chowski wrote:
> I /meant/ to run `go doc http.Handle` but I typed `go doc http.Register`
> instead. The former works fine, whereas the latter gives me an unexpected
> error:

I always use the 2 argument form; `go doc http Handle`. That way the
first argument is the package, the second the symbol you're after.
And it has the advantage that if you ask for a symbol that doesn't
exist, you get an error like you were expecting:

```
$ go doc http Register
doc: no symbol Register in package net/http
```

You're right the error message from `go doc http.Register` was
unhelpful, though, that could definitely be improved. I'd encourage
you to open an issue on github for it.

Nick
Reply all
Reply to author
Forward
0 new messages