Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Auto-complete & other issues with modules #872

Open
awfm9 opened this issue Feb 21, 2019 · 8 comments
Open

Auto-complete & other issues with modules #872

awfm9 opened this issue Feb 21, 2019 · 8 comments

Comments

@awfm9
Copy link

awfm9 commented Feb 21, 2019

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: Autocomplete working sporadically #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: Automatic import completion: favor internal dependency over external #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 awfm9 changed the title Auto-complete issues with modules Auto-complete & other issues with modules Feb 21, 2019
@dmowcomber
Copy link

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

@gad2103
Copy link

gad2103 commented Mar 4, 2019

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

@awfm9
Copy link
Author

awfm9 commented Mar 4, 2019

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

@gad2103
Copy link

gad2103 commented Mar 4, 2019

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

@malkhamis
Copy link

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.

@tappoz
Copy link

tappoz commented Oct 3, 2019

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

@wymli
Copy link

wymli commented Feb 1, 2020

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

@thejdavid
Copy link

Is there a fix to this ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants