Skip to content

x/tools/gopls: VSCode with go module suddenly shows undeclared name: L LSP[line, character] #33477

Closed
@elico

Description

@elico

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

$ go version
go version go1.12.7 linux/amd64

Does this issue reproduce with the latest release?

Yes, but only on my current Ubuntu 18.04, on a fresh Debian 10 it works as expected.

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

Ubuntu 18.04

go env Output
$ go env
GOARCH="amd64"
GOBIN="/home/eliezer/go_projects/bin"
GOCACHE="/home/eliezer/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/eliezer/go_projects"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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-build997023063=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Open Visual Studio Code.
Add the project folder V1.
Add three new xyz.go files into the project folder making it a basic V2
Opened one of the new files tls.go

What did you expect to see?

I expected the go module which uses gopls to show missing variables and other parts of the code as errors.

What did you see instead?

An screenshot link:
https://pasteboard.co/IrkFAnp.png

Lots of error lines such as below which ends with the source as LSP:

{
	"resource": "/home/eliezer/Scripts/golang-http-proxy2/filtering.go",
	"owner": "_generated_diagnostic_collection_name_#0",
	"severity": 8,
	"message": "undeclared name: RequestTimeout",
	"source": "LSP",
	"startLineNumber": 36,
	"startColumn": 27,
	"endLineNumber": 36,
	"endColumn": 41
}

{
	"resource": "/home/eliezer/Scripts/golang-http-proxy2/filtering.go",
	"owner": "_generated_diagnostic_collection_name_#0",
	"severity": 8,
	"message": "undeclared name: MaxIdleConnections",
	"source": "LSP",
	"startLineNumber": 41,
	"startColumn": 26,
	"endLineNumber": 41,
	"endColumn": 44
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeToolsThis label describes issues relating to any tools in the x/tools repository.WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.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