Vim-go question.

agolangf · 2016-12-29 05:00:11 · 670 次点击    
这是一个分享于 2016-12-29 05:00:11 的资源,其中的信息可能已经有所发展或是发生改变。

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:

Have you installed the vim-go required packages? I think its :GoInstall

kostix:

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 :GoInstallBinariescommand. 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 runs go 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 running go 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.

hoverage:

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.


入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

670 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传