Closed
Description
Gopls has some support for ad-hoc packages, which are packages defined in a directory outside of a module or GOPATH. To support them, it sets GO111MODULE=auto
and loads .
. However, I observe that gopls also load individual files eagerly, and this can lead to conflicting state.
Consider the following simple ad-hoc package:
-- a.go --
package foo
const X = 1
-- b.go --
package foo
const Y = X
If I trigger repeated reloads of b.go
(for example, by typing in an import statement in b.go), I can sometimes trigger a state where I can an "undefined name: X" diagnostics even though cross references on X work. The reason for this, I assume, is that we eagerly load file:b.go
before reloading the directory .
, resulting in multiple packages containing b.go
, one of which does not contain a.go
.
CC @adonovan