x/tools/cmd/godoc: Path mapping of module name is incorrect
StarpTech opened this issue · 3 comments
What version of Go are you using (go version
)?
go version go1.14 linux/amd64
What version of godoc are you using?
Latest version. Installed with:
GO111MODULE=off go get -u golang.org/x/tools/cmd/godoc
Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (go env
)?
go env
Output
GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/home/starptech/.cache/go-build" GOENV="/home/starptech/.config/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/starptech/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/mnt/ssd/repositories/golang-dynaday/go.mod" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build252071029=/tmp/go-build -gno-record-gcc-switches"
What did you do?
In my organization, we host on Gitlab and projects are namespaced with their "groups". My module and VCS name are git.$organization.com/$group/my-project
.
When I run godoc -http=:6060
in root and click on the package git.$organization
I see the following error in the terminal:
using module mode; GOMOD=/mnt/ssd/repositories/golang-dynaday/go.mod
2020/03/07 00:03:31 cannot find package "." in:
/src/$organization
This results in a broken UI and thus my packages aren't listed correctly.
go list -m all
list correctly all packages and modules but godoc doesn't display them.
The workaround is to remove $group
name from the module name and update all places accordingly. I'm not aware of such a constraint.
go.mod
module git.$org.com/internal/golang-dynaday
go 1.14
replace git.$org.com/internal/golang-dynaday/submodule => ./submodule
require (
git.$org.com/internal/golang-dynaday/submodule v0.0.0-00010101000000-000000000000
)
What did you expect to see?
I would expect to see all my packages and modules as listed with go list -m all
What did you see instead?
Only one entry with the name of my organization git.$organization.com
can be seen in "Third party". It looks like the current implementation can't handle arbitrary module names especially when they can't be mapped to the local filesystem.
According to @dmitshur this can be related to https://golang.org/cl/205661.
Related: #26827
@dmitshur I tested your patch but it didn't work. Only the error is gone but the packages are still not recognized.
Thanks for the detailed report and testing out that CL.
To clarify, when you write $organization
or $group
, you mean for those to be substituted by an arbitrary string, such as example
or aaa
. There isn't a $
character in the import paths, is there?
To clarify, when you write $organization or $group, you mean for those to be substituted by an arbitrary string, such as example or aaa. There isn't a $ character in the import paths, is there?
Yes, arbitrary strings.