go-plus icon indicating copy to clipboard operation
go-plus copied to clipboard

Auto-complete & other issues with modules

Open awfm9 opened this issue 6 years ago • 8 comments

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.

  1. 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.

  1. 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.

  1. 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.

  1. 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.

  1. 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.

awfm9 avatar Feb 21 '19 08:02 awfm9

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 avatar Feb 27 '19 21:02 dmowcomber

@dmowcomber that didn't work for me. Auto-complete only seems to work with stdlib and not modules/deps

gad2103 avatar Mar 04 '19 04:03 gad2103

It seems to work with packages that are installed in your GOPATH, afaik.

awfm9 avatar Mar 04 '19 06:03 awfm9

I tried to go install all my packages and it was still not working so I gave up and just bought goland.

gad2103 avatar Mar 04 '19 17:03 gad2103

I managed to fix the auto-completion problems as follows:

  1. close gocode by executing gocode exit (or gocode close) in the terminal
  2. find all binaries of gocode using which gocode and remove them
  3. install the correct gocode binary go get github.com/stamblerre/gocode
  4. navigate to the package settings for go-plus and click on View Code
  5. Search for all occurrences of mdempsky and replace them with stamblerre
  6. 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 avatar Mar 08 '19 17:03 malkhamis

@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.

tappoz avatar Oct 03 '19 13:10 tappoz

@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.

wymli avatar Feb 01 '20 06:02 wymli

Is there a fix to this ?

thejdavid avatar May 24 '20 14:05 thejdavid