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

GoInfo doesn't work on assigned variables #2119

Closed
kaihendry opened this issue Jan 7, 2019 · 5 comments
Closed

GoInfo doesn't work on assigned variables #2119

kaihendry opened this issue Jan 7, 2019 · 5 comments

Comments

@kaihendry
Copy link

What did you do? (required. The issue will be closed when not provided.)

https://s.natalian.org/2019-01-07/go-info.mp4

What did you expect to happen?

Hover over svc and for it to indicate it's type *S3

What happened instead?

Nothing

Configuration (MUST fill this out):


* go version go1.11.4 linux/amd64

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/hendry/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/hendry/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/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-build906482915=/tmp/go-build -gno-record-gcc-switches"



@bhcleek
Copy link
Collaborator

bhcleek commented Jan 7, 2019

Thank you for the report. There are some of pieces of information that could help us get to the bottom of this:

  1. Does this happen for all the identifiers on the left side of an assignment?
  2. Does it matter how long you leave the cursor in place? (I'd recommend leaving there for 20 seconds just to see)
  3. How large is your GOPATH?
  4. If you have a vendor directory for this project, how large is it?

You might consider debugging gocode to see if it's having a problem. You can do that by closing VSCode (to make sure it's gocode isn't interferring somehow) and then starting it at the commandline using:

$ gocode exit # to make sure any existing gocode are closed
$ gocode -s -sock unix -builtin -fallback-to-source -cache -debug

And then try your test again in vim-go. You should see some output in the terminal window where you're running the server.

You might consider switching to guru by setting g:go_info_mode='guru' if you're not tied to use gocode for the type info.

@kaihendry
Copy link
Author

kaihendry commented Jan 8, 2019

How come VScode is instant btw? Do they not share the same gocode?

  1. Yes
  2. Tried a longer time. No dice.
  3. 3.3GB
  4. No

https://s.natalian.org/2019-01-08/gocode-debug.mp4 <-- debugging on my Arch machine
https://s.natalian.org/2019-01-08/gocode-debug-void.mp4 <-- debugging on Void machine

gocode does seem like a mysterious beast and neovim's :GoInfo's result of vim-go: [gocode] SUCCESS is very misleading.

I'm none the wiser why it fails on Arch. I got it working on Void by install a dependency go get github.com/jmespath/go-jmespath that it seemed to be complaining about.

Back on Arch, g:go_info_mode='guru' seems to work better than without https://s.natalian.org/2019-01-08/gocode-guru.mp4

Really puzzled by these parse errors in gocode debug.

With https://s.natalian.org/2019-01-08/main.go <-- this code runs fine !

On Void it doesn't show the type, debug is:

2019/01/08 09:53:38 -------------------------------------------------------
2019/01/08 09:53:38 cache: importing: fmt, srcdir: /home/hendry/go/src/github.com/kaihendry/s3
2019/01/08 09:53:38 cache: importing: github.com/apex/log, srcdir: /home/hendry/go/src/github.com/kaihendry/s3
2019/01/08 09:53:38 cache: importing: github.com/aws/aws-sdk-go-v2/aws/awserr, srcdir: /home/hendry/go/src/github.com/kaihendry/s3
2019/01/08 09:53:38 cache: no gcexportdata file for github.com/aws/aws-sdk-go-v2/aws/awserr
2019/01/08 09:53:38 cache: importing: github.com/aws/aws-sdk-go-v2/aws/endpoints, srcdir: /home/hendry/go/src/github.com/kaihendry/s3
2019/01/08 09:53:38 cache: no gcexportdata file for github.com/aws/aws-sdk-go-v2/aws/endpoints
2019/01/08 09:53:38 cache: importing: github.com/aws/aws-sdk-go-v2/aws/external, srcdir: /home/hendry/go/src/github.com/kaihendry/s3
2019/01/08 09:53:38 cache: no gcexportdata file for github.com/aws/aws-sdk-go-v2/aws/external
2019/01/08 09:53:38 cache: importing: github.com/aws/aws-sdk-go-v2/service/s3, srcdir: /home/hendry/go/src/github.com/kaihendry/s3
2019/01/08 09:53:38 cache: no gcexportdata file for github.com/aws/aws-sdk-go-v2/service/s3
2019/01/08 09:53:38 Elapsed duration: 2.802556ms
2019/01/08 09:53:38 Offset: 0
2019/01/08 09:53:38 Number of candidates found: 2
2019/01/08 09:53:38 Candidates are:
2019/01/08 09:53:38   package s3
2019/01/08 09:53:38   type string string
2019/01/08 09:53:38 =======================================================

@bhcleek
Copy link
Collaborator

bhcleek commented Jan 8, 2019

gocode does seem like a mysterious beast

gocode is intended for autocompletion. As such, when it's used for getting type info, it only takes up to the cursor position into account. That's why you were seeing a couple of results from gocode: when on the s in s3, its' finding all in-scope identifiers that start with s. Since there's two results, vim-go doesn't know which one to display, so doesn't display any. TBH, I'd never considered this limitation of using gocode for type info before. Guru doesn't have such limitations.

and neovim's :GoInfo's result of vim-go: [gocode] SUCCESS is very misleading.
It's only telling you that the call to gocode was successful; gocode exited with a successful exit code.

You might consider raising an issue with https://github.com/mdempsky/gocode about the errors you saw later in the gocode output, though.

@kaihendry
Copy link
Author

Thanks for getting back to me, much appreciated.

Ok, I'll try use Guru instead.

Guru type info

I wonder what VScode uses, since it "just works" annoyingly in VScode land.

@bhcleek bhcleek closed this as completed Jan 9, 2019
@bhcleek
Copy link
Collaborator

bhcleek commented Jan 9, 2019

gocode is intended for autocompletion. As such, when it's used for getting type info, it only takes up to the cursor position into account. That's why you were seeing a couple of results from gocode: when on the s in s3, its' finding all in-scope identifiers that start with s. Since there's two results, vim-go doesn't know which one to display, so doesn't display any. TBH, I'd never considered this limitation of using gocode for type info before. Guru doesn't have such limitations.

I took another look at how gocode is used when getting identifier info, and realized that the information I gave you there is wrong. It actually does try to match the identifier under the cursor to the candidates that are provided from gocode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants