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: does not properly support go module on spacemac #33612

Closed
ihaveadrame opened this issue Aug 13, 2019 · 3 comments
Closed

x/tools/gopls: does not properly support go module on spacemac #33612

ihaveadrame opened this issue Aug 13, 2019 · 3 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls.
Milestone

Comments

@ihaveadrame
Copy link

ihaveadrame commented Aug 13, 2019

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

$ go version
go version go1.12.7 darwin/amd64

$ gopls version
golang.org/x/tools/gopls v0.1.2
    golang.org/x/tools/gopls@v0.1.3 h1:CB5ECiPysqZrwxcyRjN+exyZpY0gODTZvNiqQi3lpeo=

$ gopls -rpc.trace -v check /Users/alan/work/helloworld/server.go
2019/08/13 09:09:34 Info:Build info
----------
golang.org/x/tools/gopls v0.1.2
    golang.org/x/tools/gopls@v0.1.3 h1:CB5ECiPysqZrwxcyRjN+exyZpY0gODTZvNiqQi3lpeo=
    golang.org/x/sync@v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
    golang.org/x/tools@v0.0.0-20190710153321-831012c29e42 h1:4IOeC7p+OItq3+O5BWkcmVu2uBe3jekXau5S4QZX9DU=

Go info
-------
go version go1.12.7 darwin/amd64

GOARCH="amd64"
GOBIN="/Users/alan/work/goprojects/bin"
GOCACHE="/Users/alan/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/alan/work/goprojects"
GOPROXY="https://goproxy.io"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.7/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.7/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/alan/work/helloworld/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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/yn/p3b3s8lx3jzfnslp_pt2b04h0000gn/T/go-build511327668=/tmp/go-build -gno-record-gcc-switches -fno-common"

Does this issue reproduce with the latest release?

yes

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

macOS Majave 10.14.6

go env Output
$ go env
GOARCH="amd64"
GOBIN="/Users/alan/work/goprojects/bin"
GOCACHE="/Users/alan/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/alan/work/goprojects"
GOPROXY="https://goproxy.io"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.7/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.7/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/alan/work/helloworld/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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/yn/p3b3s8lx3jzfnslp_pt2b04h0000gn/T/go-build278172779=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

.
├── api
│   └── apis.go
├── go.mod
└── server.go
import (
	"fmt"
	api "helloworld/api"
)

What did you expect to see?

I hope it can properly support the go module on spacemacs.

What did you see instead?

LSP: could not import helloworld/api (no parsed files for package helloworld/api) (lsp-ui)

lsp-log

Found the following clients for /Users/alan/work/helloworld/server.go: (server-id gopls, priority 0), (server-id go-bingo, priority -1), (server-id go-ls, priority -2)
The following clients were selected based on priority: (server-id gopls, priority 0)
25.917609ms for GOROOT= GOPATH=/Users/alan/work/goprojects GO111MODULE=auto PWD=/Users/alan/ go "list" "-m" "-json" "all", stderr: <<go list -m: not using modules
>>

32.203691ms for GOROOT= GOPATH=/Users/alan/work/goprojects GO111MODULE=auto PWD=/Users/alan/ go "list" "-e" "-json" "-compiled=true" "-test=true" "-export=false" "-deps=true" "-find=false" "--" "builtin", stderr: <<>>

21.685817ms for GOROOT= GOPATH=/Users/alan/work/goprojects GO111MODULE=auto PWD=/Users/alan/ go "env" "GOPATH", stderr: <<>>

Build info
----------
golang.org/x/tools/gopls v0.1.3
    golang.org/x/tools/gopls@(devel)
    golang.org/x/sync@v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=
    golang.org/x/tools@v0.0.0-20190723021737-8bb11ff117ca => ../
    golang.org/x/xerrors@v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc=

Go info
-------
go version go1.12.7 darwin/amd64

GOARCH="amd64"
GOBIN="/Users/alan/work/goprojects/bin"
GOCACHE="/Users/alan/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/alan/work/goprojects"
GOPROXY="https://goproxy.io"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.7/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.7/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/yn/p3b3s8lx3jzfnslp_pt2b04h0000gn/T/go-build089164657=/tmp/go-build -gno-record-gcc-switches -fno-common"

28.497661ms for GOROOT= GOPATH=/Users/alan/work/goprojects GO111MODULE=auto PWD=/Users/alan/ go "list" "-m" "-json" "all", stderr: <<go list -m: not using modules
>>

29.824497ms for GOROOT= GOPATH=/Users/alan/work/goprojects GO111MODULE=auto PWD=/Users/alan/ go "env" "GOPATH", stderr: <<>>

35.87288ms for GOROOT= GOPATH=/Users/alan/work/goprojects GO111MODULE=auto PWD=/Users/alan/ go "list" "-e" "-json" "-compiled=true" "-test=true" "-export=false" "-deps=true" "-find=false" "--" "/Users/alan/work/helloworld", stderr: <<>>

356.050461ms for GOROOT= GOPATH=/Users/alan/work/goprojects GO111MODULE=auto PWD=/Users/alan/ go "list" "-e" "-json" "-compiled=true" "-test=true" "-export=false" "-deps=true" "-find=false" "--" "/Users/alan/work/helloworld/server.go", stderr: <<>>

go/packages.Load
	package = command-line-arguments
	files = [/Users/alan/work/helloworld/server.go]
go/packages.Load
	packages = 1
no signature help
	At = {0xc000220140 11475 11475}
	Failure = cannot find an enclosing function
no signature help
	At = {0xc000220140 11500 11500}
	Failure = cannot find an enclosing function
Buffer switched - ignoring reponse. Method textDocument/hover
@gopherbot gopherbot added this to the Unreleased milestone Aug 13, 2019
@gopherbot gopherbot added the gopls Issues related to the Go language server, gopls. label Aug 13, 2019
@stamblerre
Copy link
Contributor

The problem here is that you need to open your editor at the module root, i.e. the directory that contains the go.mod file. Otherwise, gopls has no way to determine the module root (see #32394). I believe that Emacs has a way of manually specifying the workspace root, though I am not sure about Spacemacs.

@ihaveadrame
Copy link
Author

ihaveadrame commented Aug 14, 2019

I decided to close this issue, maybe you are right, This is not a problem of gopls.

@ihaveadrame
Copy link
Author

@stamblerre
I solved my problem and the problem is in my spacemac environment variable. I synced it. It’s a low-level mistake, it has delayed me a lot of time, and finally thank you for your help.

@golang golang locked and limited conversation to collaborators Aug 13, 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