Atom Editor Golang - Go To Declaration not working

匿名 (未验证) 提交于 2019-12-03 08:41:19

问题:

I've done a fresh install of atom and installed go-plus package. The one feature I can't get working is the "Go To Declaration" which is why I'm still stuck in sublime land... Does anyone know if this works with golang? I't appears that I need to have ctags for my project? Whats the best way to get this going for atom? I've tried installing other packages that geverate the ctags but I don't think that helped. Has anyone got this working? What did you do?

回答1:

Fresh install of Atom 1.3.3 with go-plus 3.5.2 and it worked.

By default, the shortcut is Alt+Cmd+G, but you can change as explained here

Update December, 22th:

With the latest update of Atom (1.12.7) and go-plus (5.0.6), the hyperclick package (v 0.0.39) is installed and CMD+click will take you to the definition



回答2:

That might be related to the godef package, which has recently changed location.

See "PR 239" (merged in 7a32e22):

The godef package has been moved to github (see http://godoc.org/code.google.com/p/rog-go/exp/cmd/godef).
This change will allow Get Missing Tools to install it.

That will be available in go-plus 3.4.2 (currently I see 3.4.1 in my Atom package list)



回答3:

On Ubuntu, Press ctrl-alt-g on the variable for which you want to do "go to declaration", Atom will ask if you want to install go-def, click yes, once installed it will show you a notification, after which Go to declaration works.



回答4:

It was two things that got godef working for me:

  1. fixing GOROOT when go is installed by brew. You need to use the libexec subdirectory. See below.
  2. understanding GOPATH. It's the workspace. In Intellij terminology, the GOPATH is the path to the project. It has as immediate subfolders src, bin, and other go-specific folders.

Below is what my bash_profile looks like.

export GOPATH=$HOME/Documents/gocode export GOROOT=/usr/local/Cellar/go/1.7.1/libexec export PATH=$PATH:$GOROOT/bin export PATH=$PATH:$GOPATH/bin 

After making this change, atom (as well as emacs) started to work



回答5:

I had goplus and it wasn't working but the godef atom package worked like a charm

apm install godef



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!