cmd/doc: match major module versions greater than 1 without needing a /vN suffix
#41,501 opened on Sep 19, 2020
Repository metrics
- Stars
- (133,883 stars)
- PR merge metrics
- (No merged PRs in 30d)
Description
What version of Go are you using (go version)?
I'm using Go 1.15, but I confirmed that none of the behavior I describe below is any different as of
go version devel +a3868028ac Sat Sep 19 09:43:15 2020 +0000 linux/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
N/A
What did you do?
I have a module which uses github.com/go-chi/chi/v4 as a dependency. The go.mod contains
require (
// ...
github.com/go-chi/chi/v4 v4.0.0-rc1
// ...
)
(And it doesn't involve any other module or package named chi.)
Inside this module, I was trying to use go doc to review some documentation for this dependency.
What did you expect to see?
I should be able to use the name chi to call up package docs for github.com/go-chi/chi/v4:
$ go doc chi.get
package chi // import "github.com/go-chi/chi/v4"
func (mx *Mux) Get(pattern string, handlerFn http.HandlerFunc)
Get adds the route `pattern` that matches a GET http method to execute the
`handlerFn` http.HandlerFunc.
What did you see instead?
The name chi is not enough to get go doc to bring up package docs for github.com/go-chi/chi/v4. I need to refer to it as chi/v4:
$ go doc chi.get
doc: symbol chi is not a type in package main installed in "."
exit status 1
$ go doc chi/v4.get
package chi // import "github.com/go-chi/chi/v4"
func (mx *Mux) Get(pattern string, handlerFn http.HandlerFunc)
Get adds the route `pattern` that matches a GET http method to execute the
`handlerFn` http.HandlerFunc.
By the way, is there some other issue tracking more general go doc improvements to better work with modules? I notice that go help doc only mentions GOPATH, not modules, so I suspect that there might be more work required in this area.