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

GoDef failed when using GoModules #2137

Closed
janbaer opened this issue Jan 31, 2019 · 10 comments
Closed

GoDef failed when using GoModules #2137

janbaer opened this issue Jan 31, 2019 · 10 comments

Comments

@janbaer
Copy link

janbaer commented Jan 31, 2019

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

I've create a new project with using the Go module support, The project is located outside of the GOPATH directory. I've initialized it with go mod init github.com/janbaer/sherlock

When I'm in the main.go and I want to go to a function of sub package with using GoDef it fails.

What did you expect to happen?

It should jump to the expected function

What happened instead?

I just see the error in the status line: vim-go: [searching declaration] FAIL

When I go into the function manually I see the following output in the status line:

vim-go: func HandleI(nspect invalid type, _ invalid type, _ http.HandlerFunc, _ invalid type, ResponseWriter *http.Request, r *http.Request)

but the function name is HandleInspect. It's the same with any other function in this package and also other packages.

Navigating to local functions works. It works also in other projects without but also with GoModules support.

Configuration (MUST fill this out):

  • vim-go version: latest master

  • vimrc you used to reproduce (use a minimal vimrc with other plugins disabled; do not link to a 2,000 line vimrc):

  • Vim version (first three lines from :version):

VIM - Vi IMproved 8.1 (2018 May 18, compiled Jan 28 2019 15:24:39)
Included patches: 1-837

  • Go version (go version): 1.11.4

  • Go environment (go env):

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/jan/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/jan/Projects/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/jan/Projects/sherlock/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-build410959908=/tmp/go-build -gno-record-gcc-switches"

@janbaer
Copy link
Author

janbaer commented Jan 31, 2019

I just found the hint that GoUpdateBinaries might could help and it works now for me. But I still see this strange status line when I'm into the function:

vim-go: func HandleI(nspect invalid type, _ invalid type, _ http.HandlerFunc, _ invalid type, ResponseWriter *http.Request, r *http.Request)

@bhcleek
Copy link
Collaborator

bhcleek commented Jan 31, 2019

The function signature comes from either gocode or guru. If you're not seeing the ( in the wrong place when in GOPATH mode, then then problem doesn't lie with vim-go in this case.

@janbaer
Copy link
Author

janbaer commented Feb 1, 2019

How can I investigate what gocode returns when it'll be called from vim-go. With which parameters will it be called under the hood?

@bhcleek
Copy link
Collaborator

bhcleek commented Feb 1, 2019

  1. Set g:go_debug=['shell-commands'] so that the command and all its arguments will be output as a list when it's run. You can also see it in the output of :messages.
  2. Convert the list to a commandline, and add the -debug option.
  3. Stop any running gocode processes:
$ gocode-gomod exit
$ gocode exit
$ gocode close #(just in case you have a  nsf/gocode running)
  1. In a separate terminal window, run the command you created in step 2.

@janbaer
Copy link
Author

janbaer commented Feb 1, 2019

@bhcleek Thank you very much for your instructions. I followed and I just tried to execute the following command:

gocode-gomod -debug -sock unix -f vim -builtin -fallback-to-source -cache autocomplete /home/jan/Projects/sherlock/handlers/handlers.go 258

But it hangs and no output will be produced.

This was the command as it was in the messages list:

vim-go: job command: ['/home/jan/Projects/go/bin/gocode-gomod', '-sock', 'unix', '-f', 'vim', '-builtin', '-fallback-to-source', '-cache', 'autocomplete', '/home/jan/Projects/sherlock/ha
ndlers/handlers.go', 258]

@bhcleek
Copy link
Collaborator

bhcleek commented Feb 1, 2019

gocode is a server. After starting it on the commandline, you'll need to do the operation in Vim from which you're seeing the wrong output.

@janbaer
Copy link
Author

janbaer commented Feb 2, 2019

Okay I tried it again, but it still no output. It seems, that VIM don't talk with this instance of gocode-gomod.

I also explicitely repeated step 3 before. I started gocode in the debvug mode.

gocode-gomod -sock unix -f vim -builtin -fallback-to-source -cache autocomplete -debug

@bhcleek
Copy link
Collaborator

bhcleek commented Feb 2, 2019

gocode-gomod will only be used when you're in module mode. -debug is an option parsed by the flag, so should come before the autocomplete argument.

@janbaer
Copy link
Author

janbaer commented Feb 2, 2019

My project is using the module mode, so I think I should use gocode-gomode. But I also tried gocode with the same result. No output on the commandline..

gocode-gomod -debug -sock unix -f vim -builtin -fallback-to-source -cache autocomplete

@janbaer janbaer closed this as completed Feb 3, 2019
@janbaer
Copy link
Author

janbaer commented Feb 3, 2019

I closed the issue because the main problem with GoDef is working now for me

@thepudds thepudds mentioned this issue Feb 16, 2019
4 tasks
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