Description
What version of Go are you using (go version
)?
$ go version go version devel +dcd3b2c173 Fri Dec 27 14:52:12 2019 +0000 linux/amd64 $ go list -m golang.org/x/tools golang.org/x/tools v0.0.0-20191230220329-2aa90c603ae3 $ go list -m golang.org/x/tools/gopls golang.org/x/tools/gopls v0.1.8-0.20191230220329-2aa90c603ae3
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env GO111MODULE="on" GOARCH="amd64" GOBIN="" GOCACHE="/home/myitcv/.cache/go-build" GOENV="/home/myitcv/.config/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="linux" GOINSECURE="" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/myitcv/gostuff" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/home/myitcv/gos" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/home/myitcv/gos/pkg/tool/linux_amd64" GCCGO="gccgo" AR="ar" CC="gcc" CXX="g++" CGO_ENABLED="1" GOMOD="/home/myitcv/gostuff/src/github.com/myitcv/govim/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-build998756224=/tmp/go-build -gno-record-gcc-switches"
What did you do?
As a follow up to #36243, we are seeing some strange behaviour when it comes to diagnostics being published by gopls
which is making it hard to assert in govim
integration tests.
Consider the following setup:
-- go.mod --
module mod.com
-- main.go --
package main
func main() {
var z int
z = z
}
-- other.go --
package main
import "fmt"
func foo() {
fmt.Printf("%v")
}
Open your editor in the context of the mod.com
module, but do not open any file.
Observe that there are no initial diagnostics sent (see #36243 (comment))
Now open main.go
and you will see that diagnostics are sent for both main.go
(at version 1) and other.go
(at version 0).
Now open other.go
and you will see that diagnostics are sent for both other.go
(at version 1) and main.go
(at version 1). The main.go
diagnostics are unchanged.
Now add a blank line as the final line in the main
function in main.go
and you will see that diagnostics are sent for other.go
(at version 1), despite them not being changed from before.
Now add a blank line as the final line in the foo
function in other.go
and you will see that diagnostics are sent for main.go
(at version 2), despite them not being changed from before.
What did you expect to see?
- Initial diagnostics to be sent for both files, because both contain errors/warnings
- Diagnostics to be resent only for the file that is opened
- Diagnostics not to be resent when they haven't changed
What did you see instead?
Per above