Closed
Description
What version of Go are you using (go version
)?
(Built from CL 489076 patchset 2.)
$ go version go version devel go1.21-0e5f77a24c Fri Apr 21 14:45:51 2023 -0400 linux/amd64
Does this issue reproduce with the latest release?
Yes, but it's harder to reproduce due to #56222.
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/usr/local/google/home/bcmills/.cache/go-build" GOENV="/usr/local/google/home/bcmills/.config/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/tmp/tmp.hIhiXWubgo/.gopath/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/tmp/tmp.hIhiXWubgo/.gopath" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/local/google/home/bcmills/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/local/google/home/bcmills/go/pkg/tool/linux_amd64" GOVCS="" GOVERSION="devel go1.21-0e5f77a24c Fri Apr 21 14:45:51 2023 -0400" GCCGO="/usr/bin/gccgo" GOAMD64="v1" AR="ar" CC="gcc" CXX="c++" CGO_ENABLED="1" GOMOD="/tmp/tmp.hIhiXWubgo/go.mod" GOWORK="" CGO_CFLAGS="-O2 -g" CGO_CPPFLAGS="" CGO_CXXFLAGS="-O2 -g" CGO_FFLAGS="-O2 -g" CGO_LDFLAGS="-O2 -g" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2658695689=/tmp/go-build -gno-record-gcc-switches"
What did you do?
$ go mod init example
go: creating new go.mod: module example
$ go get -t golang.org/x/tools/gopls/test/debug@master golang.org/x/tools@master
go: added golang.org/x/tools v0.8.1-0.20230425201836-76e1037d71f8
go: added golang.org/x/tools/gopls v0.0.0-20230425201836-76e1037d71f8
$ go test golang.org/x/tools/gopls/test/debug
What did you expect to see?
The test should either pass or be skipped.
What did you see instead?
The test fails: it assumes that the golang.org/x/tools
module is located up from the gopls
module, but that assumption does not hold in the module cache. (Instead, the two modules are downloaded independently and stored in disjoint subtrees.)
$ go test golang.org/x/tools/gopls/test/debug
--- FAIL: TestTemplates (2.32s)
debug_test.go:61: compiler error, e.g. /tmp/tmp.hIhiXWubgo/.gopath/pkg/mod/golang.org/x/tools/gopls@v0.0.0-20230425201836-76e1037d71f8/internal/lsp/debug/metrics.go:8:2: could not import golang.org/x/tools/internal/event/export/metric (invalid package name: "")
FAIL
FAIL golang.org/x/tools/gopls/test/debug 2.377s
FAIL
Metadata
Metadata
Assignees
Labels
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.An issue that has been verified to require only test changes, not just a test failure.This label describes issues relating to any tools in the x/tools repository.Issues related to the Go language server, gopls.
Type
Projects
Relationships
Development
No branches or pull requests
Activity
gopherbot commentedon Apr 26, 2023
Change https://go.dev/cl/489216 mentions this issue:
test/debug: load packages from outside the gopls module
gopherbot commentedon Apr 26, 2023
Change https://go.dev/cl/489215 mentions this issue:
internal/gocommand: simplify GoVersion invocation
gopherbot commentedon Apr 26, 2023
Change https://go.dev/cl/489235 mentions this issue:
internal/lsp/safetoken: load packages in TestGoplsSourceDoesNotCallTokenFileMethods from outside the gopls module
internal/gocommand: simplify GoVersion invocation
gopls: skip tests that load gopls packages if x/tools replacement is …
gopls: skip tests that load gopls packages if x/tools replacement is …