I really try my best not to use this subreddit as stack overflow, but I am a bit stumped by an error I'm getting and can't find any evidence that anyone has ever asked about the error message I get as google returns zero results.
I got assigned an existing project and pulled the repo into my gopath, I'm trying to understand the code, so i ran :GoDef on a function and got an error I haven't seen before.
vim-go: guru: cannot load package in root of source directory GOPATH/src/github.com/name/directory/*subdirectory^@
In any other directory in my gopath, I have no problems with GoDef. I can't find any results on this error.
Has anyone dealt with this before? Can anyone explain what it is I don't understand here?
EDIT: After playing around some more, I have found that I can run :GoDef on functions that are defined in outside packages, but not ones that are defined in my main package.
评论:
x7C3:
kostix:Have you installed the vim-go required packages? I think its
:GoInstall
hoverage:Almost correct: it's
:GoInstallBinaries
. To cite the documentation:Please be sure all necessary binaries are installed (such as gocode, godef, goimports, etc.). You can easily install them with the included
:GoInstallBinaries
command. If invoked, all necessary binaries will be automatically downloaded and installed to your$GOBIN
environment (if not set it will use$GOPATH/bin
). Note that this command requires git for fetching the individual Go packages. Additionally, use:GoUpdateBinaries
to update the installed binaries.The
:GoInstall
command runsgo install
on your project.To the OP: /u/x7C3 is correct:
vim-go
by default works more like the venerable (and removed since some time ago) filetype plugin and syntax highlighter for Go once shipped with Go itself. Basically it implements a set of simple commands like runninggo fmt
on the opened file, building and installing your project, running its tests etc.In order to do real heavy-lifting,
vim-go
makes use of 3rd-party tooling which it's able to fetch from their well-known locations, compile and install in your default Go workspace, and then use.
I have. I should mention that I have 3 personal projects in my gopath that have no problems running any vim-go commands at all. It's only in this one, single, project that I cloned. I can't figure it out. Nobody has used this error message, but I was hoping that would be something obvious to people here.
I get autocompletion on all structs and functions from within other files, but I cannot jump to the definition of the struct or function using GoDef (or GoDoc even) in this one project.
