go-plus
go-plus copied to clipboard
Auto-complete & other issues with modules
All prerequisites to submit issues have been completed.
Description
I was the happiest developer in the world when go-plus brought an amazing Go environment to Atom. However, it has turned into somewhat of a nightmare since our switch to Go modules. There are a number of recurring issues that cost me a lot of time and nerves. I'm putting them in the same issue because I'm reasonably certain they are related.
Output from atom -v && apm -v
Atom : 1.22.0
Electron: 1.6.15
Chrome : 56.0.2924.87
Node : 7.4.0
apm 1.18.8
npm 3.10.10
node 6.9.5 x64
python 2.7.15rc1
git 2.17.1
Output From go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/awishformore/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/awishformore/Code/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/lib/go-1.11"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.11/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/awishformore/Code/go/crawler-framework/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-build438523287=/tmp/go-build -gno-record-gcc-switches"
Issues
I have not been able to reproduce most of these consistently.
- Auto-complete doesn't consistently work for variables. (see also: #650)
When I type a variable name, I expect to see the functions and fields available for its type. Instead, I get either nothing or an invalid type
message. This seems to happen only for variables defined in packages of the module. This is usually accompanied by the CPU fan running at top speed, so I am speculating some process is doing busy work.
- Auto-complete doesn't use up-to-date module package version.
When I type a package name of the module or a variable name of a types defined in a package of the module, I expect to get the list auto-complete for the available functions, types and variables as defined in the code. Instead, I get an outdated list of available functions, types and variables from a much older version.
- Auto-import chooses external packages over internal packages. (see also: #773)
I think this issue has previously been adequately described. I mention it for the sake of completeness and because I think it plays with the next issue.
- Auto-complete chooses external packages over already imported internal packages.
When I have imported a package from the module into a source file, I expect to get the auto-complete for that package. Instead, I get the auto-complete for an external package of the same name. For instance, we have our own cli
package that is explicitly imported in a file; the auto-complete still shows the auto-complete for the urfave/cli
package.
- Right-click to go to definition does not work with guru.
This one is minor, yet still annoying. When I use godef
, I can right-click to go to the definition of a type, for instance. With guru
, it displays the definition/signature on hover, but it does not allow me to right-click to go directly to the source.
I have also tried manually switching to stamblerre/gocode
, as mentioned in #761, which did not seem to fix any of the issues described. Rebooting only seems to fix the first issue, of everything not working at all.
I've noticed this as well. I've found that running atom with go mod disabled helps.
GO111MODULE=off {atom-executable}
on mac:
GO111MODULE=off /Applications/Atom.app/Contents/MacOS/Atom
@dmowcomber that didn't work for me. Auto-complete only seems to work with stdlib and not modules/deps
It seems to work with packages that are installed in your GOPATH, afaik.
I tried to go install all my packages and it was still not working so I gave up and just bought goland.
I managed to fix the auto-completion problems as follows:
- close gocode by executing
gocode exit
(orgocode close
) in the terminal - find all binaries of gocode using
which gocode
and remove them - install the correct gocode binary
go get github.com/stamblerre/gocode
- navigate to the package settings for
go-plus
and click onView Code
- Search for all occurrences of
mdempsky
and replace them withstamblerre
- close atom, run
gocode
in terminal, and open Atom again
^^ this fixed the auto-completion issues for me. Though, for every update to go-plus, I had to repeat these steps.
@malkhamis how do you find where to click for View Code
? When on Atom I click on Packages > Settings View > Open, then I click on "Packages", then I search for "go-plus", then I click on "Settings", then I don't find anything about gocode
in those settings.
I am experiencing very similar slow downs on Linux using Go modules. The whole OS becomes unavailable because the amount of RAM keeps growing until (I think) it starts swapping with the disk and everything is freezed. I have to wait minutes before being able to open a new terminal (with Ctrl+Alt+F2) and kill all the instances of gocode
and atom
.
@malkhamis delete the original gocode and go get github.com/stamblerre/gocode
,the stamblerre version gocode can really autocomplete in modules ,but it is now in maintenance mode ,and in my atom,it is really slow.
Is there a fix to this ?