Skip to content

Gopls breaks go mod tidy though an incorrect patch version dependency on golang.org/x/tools #64994

Closed as not planned
@Zemnmez

Description

@Zemnmez

Go version

go version go1.20.7 linux/amd64

Output of go env in your module/workspace:

thomas@DESKTOP-B82ERE8 ~/.c/b/_/a/e/o/i/l/source> go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/thomas/.cache/go-build"
GOENV="/home/thomas/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/thomas/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/thomas/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/thomas/.cache/bazel/_bazel_thomas/a41610ee02ad9c69b13020a7f1cf3deb/external/go_sdk"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/thomas/.cache/bazel/_bazel_thomas/a41610ee02ad9c69b13020a7f1cf3deb/external/go_sdk/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.20.7"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="/home/linuxbrew/.linuxbrew/bin/gcc-12"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/thomas/.cache/bazel/_bazel_thomas/a41610ee02ad9c69b13020a7f1cf3deb/external/org_golang_x_tools_gopls/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 -fdebug-prefix-map=/tmp/go-build1786368587=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Make the following go file:

//go:build tools
// +build tools

package tools //import "example.com/fake"

import (
	_ "golang.org/x/tools/cmd/goimports"
	_ "golang.org/x/tools/gopls"
)

go mod init; go mod tidy

What did you see happen?

go: creating new go.mod: module example.com/fake
go: to add module requirements and sums:
        go mod tidy
go: finding module for package golang.org/x/tools/gopls
go: finding module for package golang.org/x/tools/cmd/goimports
go: found golang.org/x/tools/cmd/goimports in golang.org/x/tools v0.16.1
go: found golang.org/x/tools/gopls in golang.org/x/tools/gopls v0.14.2
go: finding module for package golang.org/x/tools/internal/persistent
example.com/fake imports
        golang.org/x/tools/gopls imports
        golang.org/x/tools/gopls/internal/lsp/cmd imports
        golang.org/x/tools/gopls/internal/lsp/cache imports
        golang.org/x/tools/internal/persistent: module golang.org/x/tools@latest found (v0.16.1), but does not contain package golang.org/x/tools/internal/persistent

What did you expect to see?

No errors.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions