Atom Editor Golang - Go To Declaration not working

2019-04-24 11:20发布

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?

5条回答
三岁会撩人
2楼-- · 2019-04-24 11:24

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

apm install godef

查看更多
淡お忘
3楼-- · 2019-04-24 11:29

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楼-- · 2019-04-24 11:32

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楼-- · 2019-04-24 11:38

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)

查看更多
爱情/是我丢掉的垃圾
6楼-- · 2019-04-24 11:48

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

查看更多
登录 后发表回答