Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: could not import github.com/google/trillian (no parsed files for package github.com/google/trillian) #32903

Closed
DazWilkin opened this issue Jul 2, 2019 · 2 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls.
Milestone

Comments

@DazWilkin
Copy link

DazWilkin commented Jul 2, 2019

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

$ go version
go version go1.12.5 linux/amd64

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"
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/usr/local/google/home/trillian/go"
GOROOT="/usr/lib/google-golang"
GOTOOLDIR="/usr/lib/google-golang/pkg/tool/linux_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=/tmp/go-build732986152=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Updated VS Code settings per instructions:
https://github.com/Microsoft/vscode-go/wiki/Go-modules-support-in-Visual-Studio-Code
https://github.com/golang/go/wiki/gopls#vscode

{
    "go.useLanguageServer": true,
    "[go]": {
        "editor.snippetSuggestions": "none",
        "editor.formatOnSave": true,
        "editor.codeActionsOnSave": {
            "source.organizeImports": true
        }
    },
    "gopls": {
        "usePlaceholders": true // add parameter placeholders when completing a function
    },
    "files.eol": "\n", // formatting only supports LF line endings    
}

go.mod:

module github.com/DazWilkin/basic-personality

go 1.12

require (
	github.com/gogo/protobuf v1.2.1
	github.com/google/certificate-transparency-go v1.0.21 // indirect
	github.com/google/trillian v1.2.1
	github.com/grpc-ecosystem/grpc-gateway v1.9.2 // indirect
	golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 // indirect
	golang.org/x/net v0.0.0-20190628185345-da137c7871d7 // indirect
	golang.org/x/sys v0.0.0-20190626221950-04f50cda93cb // indirect
	golang.org/x/text v0.3.2 // indirect
	golang.org/x/tools v0.0.0-20190702152245-7e72c71c505f // indirect
	golang.org/x/tools/gopls v0.1.2-0.20190702152245-7e72c71c505f // indirect
	google.golang.org/grpc v1.21.1
)
GOPATH=$PWD/go
cd go/src/github.com/DazWilkin/basic-personality
GO111MODULE=on go get ./...
code --new-window .

What did you expect to see?

  • No import errors.
  • Ability to navigate to godocs
  • Code completion|help

What did you see instead?

image

And both the non-standard library imports error:

  • could not import github.com/google/trillian (no parsed files for package github.com/google/trillian)
  • could not import google.golang.org/grpc (no parsed files for package google.golang.org/grpc)

If, instead, I import old-school:

GO111MODULE=off go get ./...

It works.

I suspect I'm missing something either with this solution or with Go Modules (or both) but I'm expecting to be able to use the Go Modules (GO111MODULE=on) approach with this solution.

Is it because I'm still working under ${GOPATH} and have it set?

Perhaps related to #32762 ?

@gopherbot gopherbot added this to the Unreleased milestone Jul 2, 2019
@gopherbot gopherbot added the gopls Issues related to the Go language server, gopls. label Jul 2, 2019
@stamblerre
Copy link
Contributor

You will need to set

"go.toolsEnvVars": {
   "GO111MODULE": "on",
},

to work with modules in VSCode.

@DazWilkin
Copy link
Author

Yes, that works.

I changed the setting, deleted the ${GOPATH}/src/github.com/google/trillian, reloaded and no more import error.

Thank you!!

@golang golang locked and limited conversation to collaborators Jul 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls.
Projects
None yet
Development

No branches or pull requests

3 participants