New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Statement completion is working haphazardly #1872

Open
leidegre opened this Issue Aug 24, 2018 · 10 comments

Comments

Projects
None yet
4 participants
@leidegre

leidegre commented Aug 24, 2018

It sometimes work, most of the time not. It looks like it's working relatively well for local variables and types but not package wide stuff.

What would cause this, how do I debug this? What should I do? I'm at loss on how to get to the bottom of this so I thought I'd ask what the common issues are?

I'll gladly root cause the issue I'm just not overly familiar with how everything fits together. I didn't use to have this problem and the tooling has been working fine before but now, this is a new issue for me that is consistent on at least two of my workstations.

I've updated and installed the Go tools, on several occasions, and it is working but not particularly well.

  • go version go1.10.1 windows/amd64
  • I use a non default GOPATH but I don't think it matters, I have this problem regardless of workspace. I launch VS Code with the GOPATH environment variable set externally first
@ramya-rao-a

This comment has been minimized.

Show comment
Hide comment
@ramya-rao-a

ramya-rao-a Aug 24, 2018

Member

@leidegre This is due to our move from using nsf/gocode to its fork mdempsky/gocode as the former had issues with go 1.10 and above and the maintainer has no plans at present to fix them.

Do you see issues for symbols from external packages or even for the current package and packages form the std library?

Ensure that all the dependent packages in your current package are built. If you havent disabled the build on save feature, then a simple dummy change followed by file save should do it. Else, run Go: Build Current Package.

Member

ramya-rao-a commented Aug 24, 2018

@leidegre This is due to our move from using nsf/gocode to its fork mdempsky/gocode as the former had issues with go 1.10 and above and the maintainer has no plans at present to fix them.

Do you see issues for symbols from external packages or even for the current package and packages form the std library?

Ensure that all the dependent packages in your current package are built. If you havent disabled the build on save feature, then a simple dummy change followed by file save should do it. Else, run Go: Build Current Package.

@leidegre

This comment has been minimized.

Show comment
Hide comment
@leidegre

leidegre Aug 25, 2018

@ramya-rao-a std library appears to be OK (most of the time) symbols from external packages, not so much. Symbols from current package, appear to work fine.

If I look in the statement completion list, it says invalid type for a lot of things.

invaid type

But it can find the type in the current tcm package

same package

It cannot find the type in a related but different package ddd:

other package

If I change to a file that's in that package it works again.

ddd package

So, It appears to work for the std library and current package but not my imported package.

leidegre commented Aug 25, 2018

@ramya-rao-a std library appears to be OK (most of the time) symbols from external packages, not so much. Symbols from current package, appear to work fine.

If I look in the statement completion list, it says invalid type for a lot of things.

invaid type

But it can find the type in the current tcm package

same package

It cannot find the type in a related but different package ddd:

other package

If I change to a file that's in that package it works again.

ddd package

So, It appears to work for the std library and current package but not my imported package.

@ramya-rao-a

This comment has been minimized.

Show comment
Hide comment
@ramya-rao-a

ramya-rao-a Aug 26, 2018

Member

Try this:

  • Close all VS Code instances
  • Kill any running gocode process
  • Remove the gocode binary from your $GOPATH/bin and the corresponding code form $GOPATH/src/github.com/nsf/gocode or $GOPATH/src/github.com/mdempsky/gocode
  • If you added the go.toolsGopath setting, then use that instead of the $GOPATH above
  • Open VS Code, run Go: Install/Update Tools, select gocode to install it
  • Ensure that you haven't disabled the go.installDependenciesWhenBuilding setting
  • Ensure all dependencies are built by running Go: Build Current Package (It uses the go build -i so all dependencies will be built and installed)
  • Now try the completions
Member

ramya-rao-a commented Aug 26, 2018

Try this:

  • Close all VS Code instances
  • Kill any running gocode process
  • Remove the gocode binary from your $GOPATH/bin and the corresponding code form $GOPATH/src/github.com/nsf/gocode or $GOPATH/src/github.com/mdempsky/gocode
  • If you added the go.toolsGopath setting, then use that instead of the $GOPATH above
  • Open VS Code, run Go: Install/Update Tools, select gocode to install it
  • Ensure that you haven't disabled the go.installDependenciesWhenBuilding setting
  • Ensure all dependencies are built by running Go: Build Current Package (It uses the go build -i so all dependencies will be built and installed)
  • Now try the completions
@leidegre

This comment has been minimized.

Show comment
Hide comment
@leidegre

leidegre Aug 26, 2018

@ramya-rao-a oh dear, thanks for the help! It did not fix the problem but I noticed something which might have been the root cause. However silly...

I use this script to configure and launch my environment

set GOPATH=%~dp0
set PATH=%PATH%;%GOPATH%\bin

start code .

The GOPATH was being set with a trailing backwards slash, i.e.

When I reinstalled gocode

Installing 1 tool at C:\Users\leidegre\Source\tessin\tcm\tcm-backend\\bin
  gocode

Note the double backslash \\ at the end there.

I changed by batch script to this

set ROOT=%~dp0
set GOPATH=%ROOT:~0,-1%
set PATH=%PATH%;%GOPATH%\bin

start code .

And now it actually works. It seems silly that such a thing would cause this but I guess it did... I know that backslashes specifically on Windows can cause issues with command lines if they are at the end. If there's a shell execute somewhere in the tooling the there is a trailing backslash that could cause it.

...I could do some further digging on this, at a later point, and see if I can suggest a fix or at the very least a warning for this.

leidegre commented Aug 26, 2018

@ramya-rao-a oh dear, thanks for the help! It did not fix the problem but I noticed something which might have been the root cause. However silly...

I use this script to configure and launch my environment

set GOPATH=%~dp0
set PATH=%PATH%;%GOPATH%\bin

start code .

The GOPATH was being set with a trailing backwards slash, i.e.

When I reinstalled gocode

Installing 1 tool at C:\Users\leidegre\Source\tessin\tcm\tcm-backend\\bin
  gocode

Note the double backslash \\ at the end there.

I changed by batch script to this

set ROOT=%~dp0
set GOPATH=%ROOT:~0,-1%
set PATH=%PATH%;%GOPATH%\bin

start code .

And now it actually works. It seems silly that such a thing would cause this but I guess it did... I know that backslashes specifically on Windows can cause issues with command lines if they are at the end. If there's a shell execute somewhere in the tooling the there is a trailing backslash that could cause it.

...I could do some further digging on this, at a later point, and see if I can suggest a fix or at the very least a warning for this.

@freman

This comment has been minimized.

Show comment
Hide comment
@freman

freman Aug 28, 2018

Contributor

I had this problem on osx

I had an extra / on my go.gopath in the user settings.

Definitely worth documenting this :D

Contributor

freman commented Aug 28, 2018

I had this problem on osx

I had an extra / on my go.gopath in the user settings.

Definitely worth documenting this :D

@ramya-rao-a

This comment has been minimized.

Show comment
Hide comment
@ramya-rao-a

ramya-rao-a Aug 29, 2018

Member

Well, if it is the extra / or \ in the end that is causing this, then its definitely a bug and we should fix this.

@freman I tried with the extra / in the go.gopath setting on my mac, and I am getting the completions just fine

@leidegre I am away from my Windows machine for the next few days, so I won't be able to figure out the fix just yet. But if you are interested, debugging the Go extension is very easy and you can give it a try.

For set up read https://github.com/Microsoft/vscode-go/wiki/Building,-Debugging-and-Sideloading-the-extension-in-Visual-Studio-Code#building-and-debugging-the-extension

All completion related code is in the goSuggest.ts file. You can add a breakpoint there to start

Member

ramya-rao-a commented Aug 29, 2018

Well, if it is the extra / or \ in the end that is causing this, then its definitely a bug and we should fix this.

@freman I tried with the extra / in the go.gopath setting on my mac, and I am getting the completions just fine

@leidegre I am away from my Windows machine for the next few days, so I won't be able to figure out the fix just yet. But if you are interested, debugging the Go extension is very easy and you can give it a try.

For set up read https://github.com/Microsoft/vscode-go/wiki/Building,-Debugging-and-Sideloading-the-extension-in-Visual-Studio-Code#building-and-debugging-the-extension

All completion related code is in the goSuggest.ts file. You can add a breakpoint there to start

@leidegre

This comment has been minimized.

Show comment
Hide comment
@leidegre

leidegre Aug 29, 2018

@ramya-rao-a I'm crazy busy with a deadline this and next week but if this can remain open until then, I will get around to it, I care deeply for both the tooling and the VS Code ecosystem but since I have a viable workaround I will roll with it for now. If you want to jump on this before then, be my guest.

leidegre commented Aug 29, 2018

@ramya-rao-a I'm crazy busy with a deadline this and next week but if this can remain open until then, I will get around to it, I care deeply for both the tooling and the VS Code ecosystem but since I have a viable workaround I will roll with it for now. If you want to jump on this before then, be my guest.

@ramya-rao-a

This comment has been minimized.

Show comment
Hide comment
@ramya-rao-a

ramya-rao-a Aug 29, 2018

Member

@leidegre No problem. Just one question though. You can consistently repro this issue by adding a training \ in the end of the gopath in the settings correct?

Member

ramya-rao-a commented Aug 29, 2018

@leidegre No problem. Just one question though. You can consistently repro this issue by adding a training \ in the end of the gopath in the settings correct?

@freman

This comment has been minimized.

Show comment
Hide comment
@freman

freman Aug 29, 2018

Contributor

@ramya-rao-a I can no longer replicate it but code completion wasn't working for anything other than stdlib until I removed that slash, now it seems I can have the slash on or off.

Contributor

freman commented Aug 29, 2018

@ramya-rao-a I can no longer replicate it but code completion wasn't working for anything other than stdlib until I removed that slash, now it seems I can have the slash on or off.

@abdullah2993

This comment has been minimized.

Show comment
Hide comment
@abdullah2993

abdullah2993 Sep 22, 2018

I had the same issue turn out it only occur if you set a diffrent GOPATH from the terminal and open vscode from that teminal. The solution is to set go.toolsPath to you original GOPATH

abdullah2993 commented Sep 22, 2018

I had the same issue turn out it only occur if you set a diffrent GOPATH from the terminal and open vscode from that teminal. The solution is to set go.toolsPath to you original GOPATH

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment