Skip to content

x/tools/gopls: dependency leaks across modules #32499

@fhs

Description

@fhs

What version of Go are you using (go version)?

$ go version
go version devel +ce656af9b5 Sun Jun 2 19:28:21 2019 +0000 linux/amd64
$ gopls version
golang.org/x/tools/cmd/gopls
    golang.org/x/[email protected] h1:sU3tSV6wDhWsvf9NjL0FzRjgAmYnQL5NEhdmcN16UEg=

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/fhs/.cache/go-build"
GOENV="/home/fhs/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/fhs/go"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/big/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/big/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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-build362340636=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Load more than one module in gopls. Each module has its own workspace folder, passed in the workspaceFolders initialization option.

What did you expect to see?

No changes to go.mod file for any of the modules.

What did you see instead?

I have 2 files open in my editor, where the two files are from two different modules. When I start the LSP client, it sends a DidOpen notification for those two files. Depending on which notification was sent first, the dependencies of one module gets added to the go.mod file of the other module. Example:

DidOpen file:///path/to/mod1/foo.go
DidOpen file:///path/to/mod2/foo.go
# mod2's go.mod file will get mod1 dependencies added

Similarly, for 3 modules:

DidOpen file:///path/to/mod1/foo.go
DidOpen file:///path/to/mod2/foo.go
DidOpen file:///path/to/mod3/foo.go
# mod2's go.mod file will get mod1 dependencies added
# mod3's go.mod file will get mod1 and mod2 dependencies added

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions