Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

After upgrade to Go 1.10 intellisense autocompletion stops working #1723

Closed
ddrake17 opened this issue Jun 7, 2018 · 97 comments
Closed

After upgrade to Go 1.10 intellisense autocompletion stops working #1723

ddrake17 opened this issue Jun 7, 2018 · 97 comments

Comments

@ddrake17
Copy link

ddrake17 commented Jun 7, 2018

I upgraded my Go distribution to 1.10 on Windows 7/amd64 and intellisense autocompletion stopped working for my custom packages. It is working for the standard library however. I've researched and tried solutions (#441) but nothing is working. I uninstalled all the Go tools and reinstalled, didn't fix it. Eventually I complete deleted all the %APPDATA% and extensions data for VS Code, uninstalled and reinstalled and this still did not fix the problem!

My issue is pretty much like this old one: #167

Using the example from that issue fails to work on my setup. That is, with a custom lib package:

package lib

type T struct{}

func (t T) Do() {}

and the following main:

package main

import "lib"

type abc struct {
	t lib.T
}

func (a abc) do() {
	// I have intellisense for a.t, but not for the Do function
	a.t
}

I don't get any intellisense for the lib package. FWIW the intellisense on a.t says "invalid type".

I kept looking into this further and eventually tried running gocode directly from the command line (both from the terminal inside VS code and a powershell window outside VS code) The thing is, this works perfectly. Here's the output I get with the exact code shown above:

PS C:\Go\workspace\src\lib\cmd> gocode -in="main.go" autocomplete c184
Found 1 candidates:
  func Do()
PS C:\Go\workspace\src\lib\cmd>

I thought it might be GOPATH related but I only have one GOPATH I ever use and running Go: Current GOPATH from VS Code shows the correct one.

I'm pretty much out of ideas but I think this shows that this is vscode-go related and not gocode. Please help. Thanks!

@LiPengfei19820619
Copy link

I have the same problem with 1.10 on Windows 7/amd64.

@rodrigobahiense
Copy link

Same problem on Windows 10/amd64.

@uudashr
Copy link
Contributor

uudashr commented Jun 9, 2018

Same with me.. on Mac

@ramya-rao-a
Copy link
Contributor

Is everyone here on the latest version of the Go extension (0.6.82)?
If yes, then the one main change we did around completions is to use mdempsky/gocode instead of nfs/gocode due to the latter having issues with Go 1.10 and above. See #1645

@ddrake17 You mentioned that gocode works from the terminal for you. Please try again in the same way that the Go extension calls gocode. Which is gocode -f=json autocomplete <your-file-name> <offset>

To get the offset, you can use the extension https://marketplace.visualstudio.com/items?itemName=ramyaraoa.show-offset

Others, can you check if you are using mdempsky/gocode or nfs/gocode? Look for github.com/mdempsky/gocode or github.com/nsf/gocode in your GOPATH. If you have set, go.toolsGopath, then check for these there

@uudashr
Copy link
Contributor

uudashr commented Jun 10, 2018

FYI from command line use
gocode -f=json -in=<your-file-name> autocomplete <offset>
or
gocode -f=json autocomplete <your-file-name> <offset> but it require to insert the text from stdin.

@uudashr
Copy link
Contributor

uudashr commented Jun 10, 2018

Mine

For a. result:

$ gocode -f=json -in=/.../a-path/main.go autocomplete 180
[0,[{"class":"func","package":"","name":"do","type":"func()"},{"class":"var","package":"","name":"t","type":"invalid type"}]]

For a.t. result:

$ gocode -f=json -in=/.../a-path/main.go autocomplete 182
null

@uudashr
Copy link
Contributor

uudashr commented Jun 10, 2018

See this:
Probably these are gocode issue. For a. it result to
screen shot 2018-06-10 at 09 58 45

$ gocode -f=json -in=/.../a-path/main.go autocomplete 180
[
    0,
    [
        {
            "class": "func",
            "package": "",
            "name": "do",
            "type": "func()"
        },
        {
            "class": "var",
            "package": "",
            "name": "t",
            "type": "invalid type"
        }
    ]
]

So gocode unable to resolve the type of a.t

@uudashr
Copy link
Contributor

uudashr commented Jun 10, 2018

The nsf gocode resulting to:

[
    0,
    [
        {
            "class": "func",
            "name": "do",
            "type": "func()",
            "package": ""
        },
        {
            "class": "var",
            "name": "t",
            "type": "lib.T",
            "package": ""
        }
    ]
]

@uudashr
Copy link
Contributor

uudashr commented Jun 10, 2018

I really don't understand. This what I do:

  1. Install the old nsf gocode
  2. Then install the new mdempsky gocode using go install ./...

And everything works like a charm. I think there are issue on migration from old gocode to new gocode.

@cfloa
Copy link

cfloa commented Jun 10, 2018

I ended up reinstalling nsf/gocode after removing mdempsky/gocode and my intellisense works in VS Code as it should...

@codelinter
Copy link

codelinter commented Jun 10, 2018

So I manually installed github.com/mdempsky/gocode using go get
(Using powershell for commands below)

  1. gocode -in=".\myfile.go" autocomplete 901

  2. cat .\myfile.go | gocode autocomplete 901

Command 1. gives the right output, where as the 2. gives wrong output.

I think if vscode can switch to using 1., then it should work properly

Obviously, code has to put the latest buffer into a temp file and then use that file and -in flag.

@uudashr
Copy link
Contributor

uudashr commented Jun 10, 2018

Please do things below:

  1. gocode close
  2. gocode exit (just to make sure)
  3. Go: Install/Update Tools or install gocode go get -u github.com/mdempsky/gocode

Probably previously we missed the gocode close command. Not really sure. But hopefully works.

@codelinter
Copy link

codelinter commented Jun 10, 2018

as @ZeroFTW suggested, switch to nsf and everything is fine. mdempsky version is buggy right now as it only works with built-in packages and not externally installed ones.

@ramya-rao-a
Copy link
Contributor

@uudashr Adding the gocode close and gocode exit commands before updating the tools via the Go Install/Update Tools command should help.

@MintyOwl,

Command 1. gives the right output, where as the 2. gives wrong output.

Can you share the output of both?

Me, @uudashr and @m90 are able to get completions for external installed packages as well. My gut feel is that @uudashr's findings of issues with migration must be causing this. Can you follow the steps in #1723 (comment) and let us know if this is still a problem?

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Jun 10, 2018

Also, let's first ensure that the right gocode is being used

  • Run gocode close and gocode exit
  • Delete the folders mdempsky/gocode and nfs/gocode from your GOPATH/src and GOPATH/pkg. Delete the gocode binary from GOPATH/bin. (If you have set go.toolsGopath setting then delete the same from there)
  • Run go get -u github.com/mdempsky/gocode
  • Check the created/modified date of the gocode executable in GOPATH/bin folder. Ensure it matches the timestamp of when you ran the previous step.
  • Run gocode -s -debug
  • Try completions in VS Code

@ManuelBauer
Copy link

@ramya-rao-a
gocode close and gocode exit didn't helped, because no service was found:

./gocode close
2018/06/10 20:29:34 rpc: can't find service Server.Exit

But when I executed bin/gocode -s -debug I got the following message, that the address is already in use. In my case there was an old gocode process running. After killing the process and restarting VS Code everything went back to normal and the code completion started working again 😃

bin/gocode -s -debug
2018/06/10 20:31:32 listen unix /var/folders/7f/n0kwqvg54s72pmjdnn1xvr_c0000gn/T/gocode-daemon.manuel: bind: address already in use

@m90
Copy link
Contributor

m90 commented Jun 10, 2018

I think there are issue on migration from old gocode to new gocode.

I second what @uudashr says, I also think this is the automated migration not working as we'd like it to.

I cannot repro any of the malfunctions locally. I installed mdempsky/gocode manually when working on #1710 and have never encountered any issues since then (plus I got rid of the nsf/gocode PANIC).

This is my setup:

frederik@fr-xps:~ $ go version
go version go1.10.1 linux/amd64

===

frederik@fr-xps:~ $ code -v
1.23.1
d0182c3417d225529c6d5ad24b7572815d0de9ac
x64

===

frederik@fr-xps:ms-vscode.go-0.6.82 $ cat package.json | grep version
	"version": "0.6.82",

===

frederik@fr-xps:gocode[master] $ git log
commit 7282f446b501b064690f39640b70e1ef54806c60
Author: Matthew Dempsky <mdempsky@google.com>
Date:   Wed May 2 00:00:30 2018 -0700

    gocode: add -source flag to use srcimporter
    
    I keep seeing requests for an importer that loads directly from
    source, so I decided to implement it.
    
    Unfortunately, this is very slow currently: suggestions take about
    1.5s on my laptop. This could probably be improved with caching.

Unfortunately I think switching back to nsf/gocode would not really solve the issue as seen in #1645


Also: one possible caveat that also had me trip and think Intellisense is broken a few times already: it is important to know that autocompletion on unimported packages will only be triggered if the package name is completely unabmiguous on the system. So if you type fmt. and expect autocompletion, it might not work because there is also Hugo's fmt package (plus many more like math) alongside those in GOROOT, which makes it impossible to tell which package you are referring to, thus no Intellisense is triggered.

@codelinter
Copy link

Alright, so I just started my Windows 10 64 bit machine running go 1.10.3, and both gocode versions are showing correct results. Dont know why the discrepancies yesterday!!

But, vscode (atleast on my machine) cannot autocomplete mdempsky version. nsf version works flawlessly.

I tested on both version by completely killing the process one at a time, renaming them at $GOPATH/bin and firing vscode.

@ramya-rao-a
Copy link
Contributor

@MintyOwl

But, vscode (atleast on my machine) cannot autocomplete mdempsky version. nsf version works flawlessly.

Do you not see completions only for external packages or even for pkgs from std lib when using the mdempsky version in VS Code?

@codelinter
Copy link

Do you not see completions only for external packages or even for pkgs from std lib when using the mdempsky version in VS Code?

Autocompletion for built-in packages work , but external packages go bust.

vscode-version

@ddrake17
Copy link
Author

ddrake17 commented Jun 11, 2018

@ramya-rao-a ok I tried running the json command as you suggested however gocode just hangs when I run gocode -f=json autocomplete main.go c152, running gocode -f=json -in="main.go" autocomplete c152 with my exact example above works and I get good output:

{
    "value":  [
                  0,
                  [
                      {
                          "class":  "func",
                          "package":  "lib",
                          "name":  "Do",
                          "type":  "func()"
                      }
                  ]
              ],
    "Count":  2
}

Although I deleted the gocode binary I never deleted the folder in $GOPATH/src and I see both the nsf folder and the mdempsky (I did at multiple times try deleting all $GOPATH/pkg folders). I'm going to try deleting these and the binary and reinstalling

@ddrake17
Copy link
Author

ddrake17 commented Jun 11, 2018

I deleted the nsf and mdempsky $GOPATH/src folders and checked but there were no $GOPATH/pkg folders. I think this may be related to the invalid type as shown by @uudashr. Here's the gocode -debug -s output after deleting and reinstalling the mdempsky version and retrying autocompletion in VS code as suggested by @ramya-rao-a:

For a.:

2018/06/11 10:34:12 Got autocompletion request for 'c:\Go\workspace\src\lib\cmd\main.go'
2018/06/11 10:34:12 Cursor at: 152
2018/06/11 10:34:12 -------------------------------------------------------
package main

import "lib"

type abc struct {
        t lib.T
}

func (a abc) do() {
        // I have intellisense for a.t, but not for the Do function
        a.#
}
2018/06/11 10:34:12 -------------------------------------------------------
2018/06/11 10:34:12 Error parsing input file (outer block):
2018/06/11 10:34:12  c:\Go\workspace\src\lib\cmd\main.go:11:4: expected selector or type assertion, found ';'
2018/06/11 10:34:12 Elapsed duration: 2ms
2018/06/11 10:34:12 Offset: 0
2018/06/11 10:34:12 Number of candidates found: 2
2018/06/11 10:34:12 Candidates are:
2018/06/11 10:34:12   func do()
2018/06/11 10:34:12   var t invalid type
2018/06/11 10:34:12 =======================================================

For a.t.:

2018/06/11 10:36:12 Got autocompletion request for 'c:\Go\workspace\src\lib\cmd\main.go'
2018/06/11 10:36:12 Cursor at: 154
2018/06/11 10:36:12 -------------------------------------------------------
package main

import "lib"

type abc struct {
        t lib.T
}

func (a abc) do() {
        // I have intellisense for a.t, but not for the Do function
        a.t.#
}
2018/06/11 10:36:12 -------------------------------------------------------
2018/06/11 10:36:12 Error parsing input file (outer block):
2018/06/11 10:36:12  c:\Go\workspace\src\lib\cmd\main.go:11:6: expected selector or type assertion, found ';'
2018/06/11 10:36:12 Elapsed duration: 3ms
2018/06/11 10:36:12 Offset: 0
2018/06/11 10:36:12 Number of candidates found: 0
2018/06/11 10:36:12 Candidates are:
2018/06/11 10:36:12 =======================================================

I'll try using the nsf version next as suggested by @MintyOwl

@ddrake17
Copy link
Author

ddrake17 commented Jun 11, 2018

Confirmed, switching to nsf version worked for me as well. FWIW I used the instructions at the github.com/nsf/gocode repository to install on Windows by running go get -u -ldflags -H=windowsgui github.com/nsf/gocode

Let me know if you need more info. Thanks!

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Jun 11, 2018

Thanks for those details @ddrake17!
Unfortunately, there is still the problem of nsf/gocode having other problems with Go 1.10 and above. So switching to nsf/gocode cannot be the final solution.

I've pushed a fix that will close any currently running gocode process before attempting to update the tool using mdempsky/gocode.

I was able to replicate the issue of not getting any completions if there is a currently running gocode process of nfs/gocode and a new request is made to mdempsky. In such case, I prompt the user to kill such process manually and try again.

These 2 cases together should take care of a clean install and a possible explanation of gocode failure

Everybody in this issue, please give the below a try and share what you find.

  • Download https://github.com/Microsoft/vscode-go/blob/master/Go-latest.vsix
  • Run code --install-extension Go-latest.vsix
  • If the above fails with Error: end of central directory record signature not found, then clone this repo and use the Go-latest.vsix file from the cloned repo
  • Reload VS Code
  • Run Go: Install/Update Tools. If there is a currently running gocode process (which there will be if you were typing code in the editor before this) that the extension was not able to close, then the logs that show the progress of the tool updates will ask you to kill it and then try again
  • Kill the process manually and then run the Go: Install/Update Tools again. At this point, you should have a clean installation of mdempsky/gocode

Note that I wasn't able to repro the invalid type issue or the issue of getting completions only for the pkgs from std lib and not external pkgs. I am guessing that must be due to gocode getting into a dirty state. The above should get you to a clean state.

@m90
Copy link
Contributor

m90 commented Jun 12, 2018

@ramya-rao-a Do we know if this upstream issue is related: mdempsky/gocode#32 (it sounds very much like it)?

@ddrake17
Copy link
Author

ddrake17 commented Jun 12, 2018

@ramya-rao-a I followed your instructions and I still see the invalid type problem. In the bug report I completely removed VS code and all it's data and gocode (except the $GOPATH/src) and I'm still having this issue so I don't think it's related to stale state.

EDIT: After checking the JSON output from mdempsky/gocode after running those instructions this looks like a vscode-go issue. With the same example above and typing a. I see this:

PS C:\Go\workspace\src\lib\cmd> gocode -f=json -in="main.go" autocomplete c152 | ConvertFrom-Json | ConvertTo-Json
{
    "value":  [
                  0,
                  [
                      {
                          "class":  "func",
                          "package":  "",
                          "name":  "do",
                          "type":  "func()"
                      },
                      {
                          "class":  "var",
                          "package":  "",
                          "name":  "t",
                          "type":  "lib.T"
                      }
                  ]
              ],
    "Count":  2
}
PS C:\Go\workspace\src\lib\cmd>

Note that the type is properly recognized. In VS Code however I see this:

image

What are the implications of using nsf/gocode with Go 1.10? It seems to be working for some of us

@thatnerdjosh
Copy link

thatnerdjosh commented Jun 12, 2018

@ramya-rao-a I am noticing that even with the workaround above, in Mac, I can complete stdlib, but can't complete dep installed libraries (vendored dependencies)... I think it is an upstream issue with https://github.com/mdempsky/gocode

Can you verify it works for you with dep installed dependencies

I verified that it works for globally installed dependencies

@thatnerdjosh
Copy link

thatnerdjosh commented Jun 16, 2018

UPDATE: I found the issue with dep installed dependencies, gocode has an experimental feature to auto-compile the dependencies if they aren't compiled, this was user error on my end

For anyone else running into this, all you need to do is run:

gocode set autobuild true

I would personally say this issue can be closed, I think everything is good now 👍

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Aug 10, 2018

@LiPengfei19820619 I moved your comments to #1838. Let's continue there and save this thread from the noise

@microsoft microsoft deleted a comment from LiPengfei19820619 Aug 10, 2018
@SpencerMacKinnon
Copy link

I'm still seeing this on OSX 10.13.5, VS Code 1.26.0 4e9361845dc28659923a300945f84731393e210d x64, Go extension 0.6.88, golang 1.10.3. I delete the gocode binary from bin (nothing in src or pkg under mdempsky for that), verify the timestamp on the binary is new after running the package install, and I still seem to get the issue. When I run gocode in server / debug mode, it outputs:

2018/08/16 20:27:25 Error parsing input file (outer block):
2018/08/16 20:27:25 .../streamLogger_test.go:12:12: expected selector or type assertion, found ';'
2018/08/16 20:27:25 .../streamLogger_test.go:13:2: expected ';', found 'IDENT' LogInfo
2018/08/16 20:27:25 Elapsed duration: 11.837542ms
2018/08/16 20:27:25 Offset: 0
2018/08/16 20:27:25 Number of candidates found: 0

I think the ';' is something it does to work with vendored packages? (The function I'm trying to auto-complete is in this repository however)

If I type it out manually I can build / test with no problems.

@PaluMacil
Copy link

It looks like gocode expects you to have dependencies installed (go install or go get) so you might have to install the vendored dependencies. I'm not sure how it deals with those, but a safe bet is going into each folder and installing.

@SpencerMacKinnon
Copy link

The dependency is just a file one directory above, in the same repository. I know that they're different packages from go's perspective, but go get or go install don't seem to have any effect.

@ramya-rao-a
Copy link
Contributor

@SpencerMacKinnon When you are trying to get completions for an external package, gocode assumes that the package is already built and installed (under GOPATH/pkg). Try Go: Build Current Package or just save the file to trigger a build. The build should install all dependent packages

@SpencerMacKinnon
Copy link

Looking in my package directory, it does look like I have the pkg file, telemetry.a. Here is the output of gocode when I run in debug / server:

2018/08/20 17:19:34 =======================================================
2018/08/20 17:19:36 Got autocompletion request for '/Users/spencer.mackinnon/code/src/Go/src/<git-host>/pwm/lib-telemetry/dependency/foo.go'
2018/08/20 17:19:36 Cursor at: 125
2018/08/20 17:19:36 -------------------------------------------------------
package foo

import (
	telemetry "<git-host>/pwm/lib-telemetry"
)

func DoWork(foo int) int {
	return telemetry.#
}
2018/08/20 17:19:36 -------------------------------------------------------
2018/08/20 17:19:36 Error parsing input file (outer block):
2018/08/20 17:19:36  /Users/spencer.mackinnon/code/src/Go/src/<git-host>/pwm/lib-telemetry/dependency/foo.go:8:19: expected selector or type assertion, found ';'
2018/08/20 17:19:36 Elapsed duration: 740.491µs
2018/08/20 17:19:36 Offset: 0
2018/08/20 17:19:36 Number of candidates found: 0
2018/08/20 17:19:36 Candidates are:
2018/08/20 17:19:36 =======================================================
2018/08/20 17:19:36 Got autocompletion request for '/Users/spencer.mackinnon/code/src/Go/src/<git-host>/pwm/lib-telemetry/dependency/foo.go'
2018/08/20 17:19:36 Cursor at: 176
2018/08/20 17:19:36 -------------------------------------------------------
package foo
import <git-host>/pwm/lib-telemetry"

import (
	telemetry "<git-host>/pwm/lib-telemetry"
)

func DoWork(foo int) int {
	return telemetry.#
}
2018/08/20 17:19:36 -------------------------------------------------------
2018/08/20 17:19:36 Error parsing input file (outer block):
2018/08/20 17:19:36  /Users/spencer.mackinnon/code/src/Go/src/<git-host>/pwm/lib-telemetry/dependency/foo.go:9:19: expected selector or type assertion, found ';'
2018/08/20 17:19:36 Elapsed duration: 659.66µs
2018/08/20 17:19:36 Offset: 0
2018/08/20 17:19:36 Number of candidates found: 0
2018/08/20 17:19:36 Candidates are:
2018/08/20 17:19:36 =======================================================

And my source file:

package foo

import (
	telemetry "<git-host>/pwm/lib-telemetry"
)

func DoWork(foo int) int {
	return telemetry.
}

@ramya-rao-a
Copy link
Contributor

And is that package recent. Run go get -u <git-host>/pwm/lib-telemetry just as a last measure.
Since you are getting no candidates, that would be an issue with gocode. Please log an issue at https://github.com/mdempsky/gocode.

@SpencerMacKinnon
Copy link

Looks like an issue has been created already, mdempsky/gocode#32

@taikulawo
Copy link

I have solved this problem luckily..

my machine=> windows10 18.03 amd64

I found there are gocode.exe and gocode.exe~ in GOPATH/bin/.
In my taskmgr, there is gocode.exe~ running, not gocode.exe
so I kill gocode.exe~, delete both exe in bin/

I also delete mdempsky folder in GOPATH/src/github.com/mdempsky

finally, after run
go get -u github.com/mdempsky/gocode
everything worked!

@SpencerMacKinnon
Copy link

I completely uninstalled vscode and all extensions, then reinstalled vscode, the go extension, and ran the go extension command to install / update tools. Seemed to have done the trick this time and I'm getting autocomplete now. Thanks for the support :)

@mawasak
Copy link

mawasak commented Aug 28, 2018

In my case I removed last backslash ("") from GOROOT and GOPATH environment variables to make it work.

@phenixrizen
Copy link

Completion of external packages was disabled in @mdempsky version of gocode because no caching was implemented: mdempsky/gocode#32

I've created a pull request with the caching and external packages enabled by default. The pull request is here: mdempsky/gocode#48 Just waiting on him to merge it.

@xlucas
Copy link

xlucas commented Sep 13, 2018

Did anyone make it work with projects residing outside of $GOPATH ?

@daenney
Copy link

daenney commented Sep 20, 2018

Is there any way to tell VS Code to pass -source to gocode? I don't have a big GOPATH and not having completion for external packages is proving to be rather frustrating.

@lsytj0413
Copy link

use mdempsky/gocode instead of mdempsky/gocod solve my problem.

@daenney
Copy link

daenney commented Sep 21, 2018

Given that the former is already what's used I doubt that's the solution 😶.

@ramya-rao-a
Copy link
Contributor

@daenney Can you try the below?

  • Run Go: Build current package. This uses the -i flag when running go build which will ensure all the dependent packages are installed
  • From this point gocode should be able to give you completions as it looks at only the installed packages to provide the results.

@andreagrandi
Copy link

gocode close (no exit available in 1.11 version) and reinstalling tools worked for me. Code completion is now working again. Before I could only see one entry which was PANIC

@weeezes
Copy link

weeezes commented Oct 14, 2018

Go 1.11 and VSCode 1.28.1, the Go extension installs two flavors of gocode:

Installing 2 tools at <$GOPATH>/bin
  gocode
  gocode-gomod

Installing github.com/mdempsky/gocode SUCCEEDED
Installing github.com/stamblerre/gocode SUCCEEDED

All tools successfully installed. You're ready to Go :).

VSCode starts gocode-gomod, but that doesn't work. All it ever suggests is PANIC. Running gocode-gomod -s -debug outputs nothing. Removing gocode-gomod doesn't help, VSCode just starts to complain that gocode needs to be installed:

To provide auto-completions when using Go modules, we are testing a fork(github.com/stamblerre/gocode) of "gocode" and an updated version of "gopkgs". Please press the Install button to install them.

Solution

gocode-gomod close
cd $GOPATH/bin
rm gocode-gomod
ln -s gocode gocode-gomod

😛

@ramya-rao-a
Copy link
Contributor

@weeezes Do you get prompted to install gocode-gomod when you are NOT using Go modules in your project?

@gencer
Copy link

gencer commented Oct 25, 2018

On my case, after 5-10 minutes VSCode stops autocompleting. I had to restart VSCode workspace over and over again.

I do not know if my case is related to this issue but it makes me nuts here. Every project, just 5 minutes then no autocomplete anymore. Either click few files and wait 1-2 mins. to go restart itself (i think thats what it does) or close and reopen project.

@jcalvarado1965
Copy link

Not sure if this is related to the above. For me (go 1.11, Windows 10) auto-complete is not working for any packages outside of GOROOT. Debugging gocode I traced the issue to importer.joinPath in importer.go. This function is converting underscores to dashes in the GOOS_GOARCH part of the path. It is not clear to me why this is being done, but causes the search for binaries to fail, as the directory in my case has underscores (i.e. pkg/windows_amd64). Can anybody shed some light as to why this conversion is being done (maybe I'm missing something obvious)?

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Nov 2, 2018

@jcalvarado1965 Are you using modules? If yes, then please log an issue at https://github.com/mdempsky/gocode/, else log it at https://github.com/stamblerre/gocode

@gencer What version of Go are you using? Please try the below to figure out if gocode is slow or VS Code is slow in giving completions.

  • gocode exit or gocode close
  • gocode -s -debug This starts gocode in debug mode and will give completion results every time gocode is called from VS Code
  • Start using VS Code. When you see the slowness, go back to the terminal where you started gocode -s -debug to see if gocode is returning the data slower or not

@ramya-rao-a
Copy link
Contributor

This thread has gone too long and each person here might be facing completion issues for different reasons. Half of us here have already found solutions one way or the other. Therefore, I will be closing this thread.

The mdempsky/gocode fork is much more stable than a few months ago.
If you are using Go modules, you will be prompted to install another fork of gocode which is also pretty stable.

If you see any issues follow the below which I have also captured in our FAQ:

  • If this is for symbols from external packages, then ensure they installed first. You can do this by either running Go: Build Current Package which will install all dependencies or install the dependencies manually yourself using go install.
  • If it still doesnt work, run gocode close or gocode exit in a terminal and try again.
  • If it still doesnt work, run Go: Install/Update Tools, choose gocode to update the tool. Choose gocode-gomod if you are using Go modules
  • If it still doesnt work, run gocode close or gocode exit followed by gocode -s -debug in a terminal and try again. Results from gocode will show up in the terminal.
    If you see expected results in the terminal, but not in VS Code, log an issue in the vscode-go repo, else
    log an issue in the gocode repo. If you are using Go modules, log the issue in https://github.com/stamblerre/gocode

@microsoft microsoft locked as resolved and limited conversation to collaborators Nov 2, 2018
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