go: gopls: no metadata import error

I am using the latest version of gopls in vscode. On this import:

import . "github.com/onsi/gomega/gstruct" 

I get the error: could not import github.com/onsi/gomega/gstruct (no metadata for github.com/onsi/gomega/gstruct) LSP

Importing the parent package works fine

import . "github.com/onsi/gomega" 

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

$ go version
go version go1.12.1 darwin/amd64
$ gopls version
golang.org/x/tools/cmd/gopls
    golang.org/x/tools@v0.0.0-20190524140312-2c0ae7006135 h1:5Beo0mZN8dRzgrMMkDp0jc8YXQKx9DiJ2k1dkvGsn5A=

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=""
GOCACHE="/Users/nilswerner/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/nilswerner/Code/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.1/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.1/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/rw/0_ws_7zx40q15hshvt40bdlc0000gn/T/go-build110599491=/tmp/go-build -gno-record-gcc-switches -fno-common"

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 8
  • Comments: 22 (10 by maintainers)

Commits related to this issue

Most upvoted comments

Same exact problem here. killall gopls fixed it for me πŸ˜’

Thanks for the reports. I think the issue is that we don’t re-run go/packages.Load if an import has gone from unresolved to resolved, only if the list of imports has changed. I will aim to have a fix ASAP.

The CL I submitted above should address this problem. Can you sync to the latest gopls and see if it helps?

The issue no longer shows with this fix for me. Thanks! πŸ‘

After I restart the error will disappear, and then reappear later.