# x/tools/gopls: autocomplete not working as expected #32654

Closed
opened this issue Jun 17, 2019 · 9 comments
Closed

# x/tools/gopls: autocomplete not working as expected#32654

opened this issue Jun 17, 2019 · 9 comments
Labels
Milestone

$go version go version go1.12.6 windows/amd64  ### Does this issue reproduce with the latest release? Yes ### What operating system and processor architecture are you using (go env)? Windows 10 1903 x64 uses Ryzen 3 processor. go env Output $ go env
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\gence\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=D:\Go\
set GOPROXY=
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-LD:\Go\/src/mingw-4.7.2-64 -lchilkatExt-9.5.0 -lws2_32 -lstdc++
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\gence\AppData\Local\Temp\go-build166751930=/tmp/go-build -gno-record-gcc-switches


### What did you do?

Trying to see members of an object or class. See below GIF animations.

### What did you expect to see?

I would like to see members of FileInfo or cli.

### What did you see instead?

Sometimes I get intellisense work but mostly it behaves like that variable/object doesn't exists at all. So, no auto-complete.

Autocomplete issue:

• As you can see req barely completes. Above works below not. Most of my code is like this.

Also few samples:

and...

Here is logfile: logfile.log

Logfile is big, i couldn't paste here. (max. allowed size exceeded).

This logfile is belongs to info. (info balya.FileInfo) sample above GIF. I should see FileInfo's members however, even info variable is not auto-completed.

For now, I installed from a commit that committed on May 24, 2019. Which works perfectly.

added this to the Unreleased milestone Jun 17, 2019
added the label Jun 17, 2019
mentioned this issue Jun 17, 2019

### stamblerre commented Jun 17, 2019

 So interestingly enough, there are no errors in your log. There is only one case where the textDocument/completion request returns no results. If you type out "info" can you jump to definition on it?

### gencer commented Jun 17, 2019 • edited

 I can't. I illustrated 2 things in below. One is info.Authorization. (Authorization as string is in struct). And other one is invokeHookSync. As you can see i can ctrl+click on invokeHookSync however, when I type, no such method exists. If i manually enter that, i can't go to that definition. I also captured logs during this GIF recording. I've attached both below. Let me know if you need anything else. logfile.log

### muirdm commented Jun 18, 2019 • edited

 I see various errors like FromUTF16Column: chr goes beyond the line, which usually means file contents have gotten out of sync between your editor and gopls. If things get out of sync then everything breaks. An easy way to check if this is happening: Add "-debug localhost:8080" to gopls cil flags (or change port to whatever you want). Restart gopls either by killing the process or by reloading in your editor Wait for issues to start happening in a file Open your browser to localhost:8080 and navigate the gopls cache links to find the file in question Compare the contents displayed in the browser with what is in your editor If they don't match, then things have gotten out of sync. If they do match, I am out of ideas.

### SirAlvarex commented Jun 18, 2019 • edited

 I'm having the exact same issue as this user. For me it happens from the very beginning, so I was able to capture the log at a minimal size. Log File: gopls.log If I run gopls for awhile, I sometimes am able to see this error pop up: [Error - 3:14:44 PM] send textDocument/codeAction#49 line is beyond end of file  Sadly, the Cache does look to be exactly correct. It updates with every keystroke to the correct contents. Go INFO: go version go1.12.4 windows/amd64 set GOARCH=amd64 set GOBIN= set GOCACHE=C:\Users\kygordon.NORTHAMERICA\AppData\Local\go-build set GOEXE=.exe set GOFLAGS= set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOOS=windows set GOPATH=C:\Users\Public\Development\go set GOPROXY= set GORACE= set GOROOT=C:\Go set GOTMPDIR= set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64 set GCCGO=gccgo set CC=gcc set CXX=g++ set CGO_ENABLED=1 set GOMOD= set CGO_CFLAGS=-g -O2 set CGO_CPPFLAGS= set CGO_CXXFLAGS=-g -O2 set CGO_FFLAGS=-g -O2 set CGO_LDFLAGS=-g -O2 set PKG_CONFIG=pkg-config set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\KYGORD~1.NOR\AppData\Local\Temp\go-build225681462=/tmp/go-build -gno-record-gcc-switches  Is there any other info I can provide to help debug this issue? EDIT: Okay the problem just went away when I enabled GO111MODULES=on . Originally I had to disable the modules because of gopls taking up over 4GB of memory on an older version. I'll operate with the modules being enabled for awhile and see if the issue props up again. But issues with modules disabled could be a consistent setting between myself and the original poster.

### stamblerre commented Jun 28, 2019

 @gencer: Are you still seeing this issue on the latest version of gopls (go get -u golang.org/x/tools/gopls@master)? I just fixed an issue relating to race conditions, so I wonder if this could be related.

### gencer commented Jun 28, 2019 • edited

 when using without GO111MODULES=on and with dep, autocomplete still broken. When I convert project to go.mod and enable go modules, all works.

### stamblerre commented Jun 28, 2019 • edited

 Can you share the full logs that you see in \$GOPATH mode? It's possible that gopls is playing badly with dep.

### gencer commented Jun 30, 2019 • edited

 @stamblerre, sorry for late reply. See, I am trying to reproduce same behavior on my project since 2 days that uses dep, but it seems it just works. I am constantly watching and will record both GIF and a log for this when i face with same issue. But it seems fixed here. Dunno why i got wrong behavior in the first place. Perhaps, something was different at that time but as i said, it just works at the moment. Thank you so much for your help & fast fixes for both of my issues!