Skip to content

x/tools/cmd/gopls: errors reported in package with no errors #32247

Closed
@myitcv

Description

@myitcv

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

$ go version
go version go1.12.5 linux/amd64
$ go list -m golang.org/x/tools
golang.org/x/tools v0.0.0-20190524210228-3d17549cdc6b

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
GOARCH="amd64"
GOBIN="/home/myitcv/gostuff/src/github.com/myitcv/govim/cmd/govim/.bin"
GOCACHE="/home/myitcv/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/myitcv/gostuff"
GOPROXY="https://proxy.golang.org/"
GORACE=""
GOROOT="/home/myitcv/gos"
GOTMPDIR=""
GOTOOLDIR="/home/myitcv/gos/pkg/tool/linux_amd64"
GCCGO="gccgo"
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-build230798786=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Opened a file in Vim (using govim) that is part of a package that compiles and on which tests pass; received the following error message:

failed to run analyses for file:///home/myitcv/gostuff/src/github.com/myitcv/govim/cmd/govim/main.go: analysis skipped due to errors in package: [/home/myitcv/gos/src/net/lookup_unix.go:324:23: undeclared name: cgoLookupPTR /home/myitcv/gos/src/net/lookup_unix.go:124:24: undeclared name: cgoLooku
pCNAME /home/myitcv/gos/src/net/lookup_unix.go:108:23: undeclared name: cgoLookupPort /home/myitcv/gos/src/net/lookup_unix.go:96:24: undeclared name: cgoLookupIP /home/myitcv/gos/src/net/lookup_unix.go:81:24: undeclared name: cgoLookupHost]

This appears to have been introduced as part of https://go-review.googlesource.com/c/tools/+/178681

What did you expect to see?

No error message.

What did you see instead?

The above error message.


cc @stamblerre @ianthehat

Activity

added
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
goplsIssues related to the Go language server, gopls.
on May 25, 2019
added this to the Unreleased milestone on May 25, 2019
stamblerre

stamblerre commented on May 25, 2019

@stamblerre
Contributor

Is this error message logged or shown as a diagnostic? That CL changed it so that it would not show that diagnostic message anymore.

myitcv

myitcv commented on May 25, 2019

@myitcv
MemberAuthor

Sorry, I forgot to include that critical detail: it's logged.

myitcv

myitcv commented on May 25, 2019

@myitcv
MemberAuthor

It comes through as an error message though; so my expectation was the user should know about it. i.e. there has been an error, something has gone wrong.

jan-xyz

jan-xyz commented on May 26, 2019

@jan-xyz

I encounter the same error. It occurs when I freshly start vim. If I leave the file/buffer open for a while it starts working after a minute or so. I haven't found the right timing yet. I just opened the buffer switched to this tab to describe the problem, went back to verify the error and the error was gone. I tried that a few times and it seemed to solve the error. Could it be that the server needs a while to start?

I found this recent change which you labeled as "fixing a race condition" and it is concerned with package scanning. If I install gopls before that commit, the error is gone.

golang/tools@d532c07

My setup is neovim with languageClient-neovim and gopls. If I can help in any way hit me up!

myitcv

myitcv commented on May 26, 2019

@myitcv
MemberAuthor

I think the other point to note, at least in my case, is that there should not be any type checking errors. The package in question compiles without error.

mathieupost

mathieupost commented on May 27, 2019

@mathieupost

Exact same issue here with latest version from master. Package compiles, but I'm getting the same error message from gopls.

elvizlai

elvizlai commented on May 28, 2019

@elvizlai

[Error - 上午9:17:45] failed to run analyses for file:///Users/elvizlai/xxxx/main.go: analysis skipped due to errors in package: [/usr/local/Cellar/go/1.12.5/libexec/src/net/lookup_unix.go:324:23: undeclared name: cgoLookupPTR /usr/local/Cellar/go/1.12.5/libexec/src/net/lookup_unix.go:124:24: undeclared name: cgoLookupCNAME /usr/local/Cellar/go/1.12.5/libexec/src/net/lookup_unix.go:108:23: undeclared name: cgoLookupPort /usr/local/Cellar/go/1.12.5/libexec/src/net/lookup_unix.go:96:24: undeclared name: cgoLookupIP /usr/local/Cellar/go/1.12.5/libexec/src/net/lookup_unix.go:81:24: undeclared name: cgoLookupHost]
[Trace - 9:17:54 AM] Sending request 'textDocument/hover - (4)'.

zchee

zchee commented on May 28, 2019

@zchee
Contributor
stamblerre

stamblerre commented on May 28, 2019

@stamblerre
Contributor

I believe that these errors are related to build tags / CGO, which is why the package compiles but still has errors. They didn't appear before because of a race condition. However, these errors are being logged, rather than published as diagnostics, so I'm wondering why they are being shown to the user? I would not expect these to be user facing errors.

gopherbot

gopherbot commented on May 28, 2019

@gopherbot
Contributor

Change https://golang.org/cl/179218 mentions this issue: internal/lsp: run analyses despite some errors

zchee

zchee commented on May 28, 2019

@zchee
Contributor

@stamblerre

I believe that these errors are related to build tags / CGO

I think so too, occur only on darwin.

However, these errors are being logged, rather than published as diagnostics, so I'm wondering why they are being shown to the user?

At least the autozimu/LanguageClient-neovim will display internal error if server side has error. This implements different to show diagnostic. Therefore user shown(maybe)
Note that I don't know vscode behavior.

myitcv

myitcv commented on May 28, 2019

@myitcv
MemberAuthor

I believe that these errors are related to build tags / CGO, which is why the package compiles but still has errors

Is this being tracked somewhere? Because there should be no errors, at least in the instance I reported here.

However, these errors are being logged, rather than published as diagnostics, so I'm wondering why they are being shown to the user?

If an error is reported by gopls, what is the expectation on the client?

An error of this sort suggests to me (although I'm hoping the spec is more prescriptive) "there was a problem with the language server, you should know about this"

13 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.goplsIssues related to the Go language server, gopls.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @elvizlai@myitcv@jan-xyz@mathieupost@stamblerre

        Issue actions

          x/tools/cmd/gopls: errors reported in package with no errors · Issue #32247 · golang/go