-
Notifications
You must be signed in to change notification settings - Fork 645
Auto-completion doesnt when using Go modules, if the pkg hasnt been imported #1944
Comments
@ramya-rao-a thanks for reporting this. I just enabled issues and copied it to stamblerre/gocode#3. |
You, guys, are awesome keeping on top of these things the way you do!!! |
@stamblerre Thanks! I'll keep this issue open because invariably, folks will log an issue in this repo. |
To be fair, it also happens with imported packages. |
@JoseFMP, autocompletion that works for Go modules is currently in beta for VSCode (https://github.com/Microsoft/vscode-go/wiki/Use-the-beta-version-of-the-latest-Go-extension). If you use that, imported packages should autocomplete. |
@stamblerre I tried installing according to your suggestion, restarting VSCode but auto completion still doesn't happen if the project is outside the $GOPATH. |
@joaoferrao Did VSCode prompt you to install the gocode-gomod tool, and did you install it? There is a separate version of gocode that works specifically for modules. |
@stamblerre first time around yes, but I didn't know I should also install beta version of the extension. Then I reinstalled VSCode, installed beta version but wasn't asked to install the fork. Anyway to force installation of the said fork? |
@joaoferrao: Yep, just execute the following commands:
You should end up with a tool |
@stamblerre thank you for getting back so fast, but I still am in no luck. I still only see the "PANIC". I also confirm I have the beta version of the Go extension: Is there anything else I can check? Any setting I should enforce in the settings.json for the go extension? |
@joaoferrao I'd recommend running |
@stamblerre outstanding support, thanks!! Maybe would be worthwhile So for others who end up here with the same issue: cd /tmp
curl -O https://github.com/Microsoft/vscode-go/releases/download/latest/Go-0.6.92-beta.1.vsix
code --install-extension Go-latest.vsix
go get -u -d github.com/stamblerre/gocode
go build -o $GOPATH/bin/gocode-gomod github.com/stamblerre/gocode
gocode close
gocode-gomod close Kill VSCode and relaunch. Thanks again. |
@joaoferrao awesome, glad it works! |
Running package version I want to confirm that the package is found But once I add a dot to autocomplete the package, nothing is returned I go back to step one to manually import the package, there is no autocompletion on the package Not until I save the file with the import added, will I get an autocomplete list for my package Hope this helps! Keep up the good work. |
@zeeraw yep, this issue is tracked in stamblerre/gocode#3. It's actually the result of a problem in the go/packages API that still needs to be solved. I will update on the issue once the go/packages API has fixed this problem. |
@stamblerre so the go extension decided to update from beta to the latest release and clearly is not behaving correctly (the beta seemed more stable). I tried repeating the process for installing the beta versions .vsix files but: $ code --install-extension Go-0.6.94-beta.5.vsix
Corrupt ZIP: end of central directory record signature not found |
@joaoferrao, I think this is probably a question for @ramya-rao-a? |
OK... just found out it's a problem related of downloading it with curl... |
@nezorflame: in the case where "id" had an invalid type, there appears to be a red underline beneath the import, so I wonder if that's related to the issue. I'm also not sure why gocode would behave differently depending on the location of the code, but I would guess that it's not switching between the module-unaware and module-aware versions of gocode correctly in these cases. VSCode-Go checks that value of |
@stamblerre Are you able to repro that as well? i.e insider GOPATH with |
@ramya-rao-a @stamblerre after some research, it seems that if the file's not saved yet, these So, basically, you can't have autocomplete, auto-import etc. until your file is saved, which renders the features useless. Some examples: @ramya-rao-a BTW, is my issue still in the scope of the current one, or do I need to create a new one? |
@ramya-rao-a, save or not. Anything outside of current file does not auto-complete. Only internal (core) is getting autocompleted. (Like Update:
VSCode=1.29.0
Update 2: See: mdempsky/gocode#84 |
@gencer VSCode uses @stamblerre's fork of this lib for modules as |
@ramya-rao-a: I am pretty sure that I can reproduce the issue, though my VSCode-Go settings are very strange at this point so it's possible I'm missing something. When I set @nezorflame: your issue is known and tracked by stamblerre/gocode#3. @gencer: is this related to the bug you already filed here mdempsky/gocode#84? Are you using modules? mdempsky/gocode does not support modules, so if you are experiencing issues with completion using Go modules, then it would be best to file a separate issue under stamblerre/gocode. |
@gencer @nezorflame Can you try running Once gocode is running in server mode, the same is re-used everytime we ask for suggestions. It may happen the current running instance isnt aware of the GO111MODULE env var and has to be restarted? |
@ramya-rao-a, My issue is about generic autocomplete but not modules (so no *-gomod running). I will continue this issue on other repository. For now, I will follow there. |
@ramya-rao-a just checked.
~ ps ax | grep gocode | grep -v grep
1454 ?? S 0:00.04 /Users/nezorflame/Go/bin/gocode -s -sock unix -addr 127.0.0.1:37373
~ ps ax | grep gocode | grep -v grep
5108 ?? S 0:00.08 /Users/nezorflame/Go/bin/gocode-gomod -s -sock unix -addr 127.0.0.1:37373 Seems to me that vscode-go ignores |
when i run ~/go/bin
0² ./gocode close
2018/11/26 21:47:19 dial unix /var/folders/j3/1mmzgr1j51s_kgdg28ksn7b40000gn/T/gocode-daemon.shaodahong: connect: no such file or directory |
@shaodahong: that just means that your gocode server wasn't running. |
@stamblerre I know when I coding in vscode , gocode start run, but autocomplete still bad, I have some question if run if run go env 0² go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/shaodahong/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/shaodahong/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/shaodahong/Workspace/demo/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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/j3/1mmzgr1j51s_kgdg28ksn7b40000gn/T/go-build051668293=/tmp/go-build -gno-record-gcc-switches -fno-common" |
@shaodahong: just to clarify, are you having the same problem as @nezorflame? When you open a file in a package that uses modules, which version of gocode gets started? Does |
@stamblerre similar, when use module autocomplete fail, version 0.7.0, mac version 10.14 (18A391) |
new log 0² gocode-gomod -s -debug
2018/11/27 12:29:43 Got autocompletion request for '/Users/shaodahong/Workspace/demo/main.go'
2018/11/27 12:29:43 Cursor at: 30
2018/11/27 12:29:43 -------------------------------------------------------
package main
func main() {
f#
}
2018/11/27 12:29:43 -------------------------------------------------------
2018/11/27 12:29:44 Elapsed duration: 195.027647ms
2018/11/27 12:29:44 Offset: 0
2018/11/27 12:29:44 Number of candidates found: 3
2018/11/27 12:29:44 Candidates are:
2018/11/27 12:29:44 const false untyped bool
2018/11/27 12:29:44 type float32 float32
2018/11/27 12:29:44 type float64 float64
2018/11/27 12:29:44 =======================================================
2018/11/27 12:29:44 Got autocompletion request for '/Users/shaodahong/Workspace/demo/main.go'
2018/11/27 12:29:44 Cursor at: 33
2018/11/27 12:29:44 -------------------------------------------------------
package main
func main() {
fmt.#
}
2018/11/27 12:29:44 -------------------------------------------------------
2018/11/27 12:29:44 Elapsed duration: 114.33626ms
2018/11/27 12:29:44 Offset: 0
2018/11/27 12:29:44 Number of candidates found: 0
2018/11/27 12:29:44 Candidates are:
2018/11/27 12:29:44 =======================================================
2018/11/27 12:29:44 Got autocompletion request for '/Users/shaodahong/Workspace/demo/main.go'
2018/11/27 12:29:44 Cursor at: 46
2018/11/27 12:29:44 -------------------------------------------------------
package main
import "fmt"
func main() {
fmt.#
}
2018/11/27 12:29:44 -------------------------------------------------------
2018/11/27 12:29:44 Elapsed duration: 113.933882ms
2018/11/27 12:29:44 Offset: 0
2018/11/27 12:29:44 Number of candidates found: 0
2018/11/27 12:29:44 Candidates are:
2018/11/27 12:29:44 =======================================================
|
@shaodahong: what changed between this and your other comment (#2148 (comment))? |
Gave HEAD version of Piece of code: package main
type A struct {
S string
}
func main() {
a := A{}
} Saved outside Preparation:
Tests:
package main
import (
"fmt"
)
type A struct {
S string
}
func main() {
a := A{}
fmt
}
|
Still, there's a problem of vscode-go launching the wrong version of "go.toolsEnvVars": {
"GO111MODULE": "on"
} ...being set inside 'User preferences'. This doesn't happen outside of @ramya-rao-a is there any way to debug this behavior so I could help with solving this? |
@stamblerre new log I delete |
|
@shaodahong you have to force Regarding the IDEA plugin, vscode-go currently doesn't have such a setting (correct me @ramya-rao-a if I'm wrong). |
I found and fixed this issue with c026b8c, so if you follow the instructions to install the latest beta for VSCode-Go, you should be able to see the fix (https://github.com/Microsoft/vscode-go/wiki/Use-the-beta-version-of-the-latest-Go-extension). Otherwise, the fix will be out in the next release. |
While it definitely works now, I believe that this new release broke |
oh, if you don't import |
@shaodahong: that is the intended behavior. mdempsky/gocode offers completions for the standard library if it's not imported, but we aren't able to do that for stamblerre/gocode. @nezorflame: I would imagine that the definition breakage is unrelated to this bug. I know there have been some issues with godef, though I think they should be fixed soon. It might be worth checking out the issues on https://github.com/ianthehat/godef. |
@stamblerre thank you |
@stamblerre agreed, thanks! |
The issue of GO111MODULES not being respected and gocode-gomod not being launched is fixed. Closing this issue. |
Using https://github.com/stamblerre/gocode and the 0.6.90 version of this extension
In the below case we dont get any completions.
Update the
quote.
above toquote.Hello()
, save the file. The next time auto-completions work@stamblerre Logging this issue here for tracking purposes as your fork doesnt support logging issues
The text was updated successfully, but these errors were encountered: