gocode外部包在VSCode中没有给出建议。

huangapple go评论113阅读模式
英文:

gocode external package give no suggestion for vscode

问题

我的自动完成/智能感知在从Visual Studio Code的Go扩展升级后停止工作:https://github.com/microsoft/vscode-go

我在那里打开了一个问题,但我认为这可能与gocode有关。

我正在运行Windows 10,Go版本1.5.1,Visual Studio Code 0.10.5和Go扩展0.6.21。在更新之前一切正常,我使用的是Go扩展0.6.17。

问题是,对于内部包,建议/智能感知可以工作,但是当我写.或按下ctrl+空格时,每个外部包都不再提供建议。甚至net/http或核心Go包也不起作用。

我想尝试运行gocode,看看它实际返回了什么,所以我查看了扩展的代码,它执行了一个类似于这样的子进程:gocode -f=json autocomplete filename offset

不太确定如何获取offset或它代表什么,它是触发自动完成的位置的字节数吗?无论如何,当我运行这个命令时,没有输出,我也没有返回到提示符,我必须按CTRL+C才能返回。

我在Google上也找不到任何有趣的东西,可能是搜索错误或者不知道该搜索什么。

有人有想法吗?运行gocode的目的是看看gocode是否为外部包返回了建议,如果是的话,那么扩展就有问题。

如果gocode没有返回任何内容,那么这意味着它现在无法正常工作,我能做些什么?

谢谢

编辑1:根据kostya的答案,从gocode的日志中可以看到:

2015/12/23 07:26:11 导入路径“github.com/gocraft/web”未解析
2015/12/23 07:26:11 Gocode的构建上下文是:
2015/12/23 07:26:11  GOROOT: c:\go
2015/12/23 07:26:11  GOPATH:
2015/12/23 07:26:11  GOOS: windows
2015/12/23 07:26:11  GOARCH: amd64
2015/12/23 07:26:11  GBProjectRoot: ""
2015/12/23 07:26:11  lib-path: ""

看起来我的GOPATH变量没有被评估,但它是设置好的,当我运行echo %GOPATH%时,我收到了正确的值。

英文:

My auto-complete / intellisense stopped working after upgrading from the Go extension here of Visual Studio Code: https://github.com/microsoft/vscode-go

I've opened an issue in there, but I'm thinking this might have to do with gocode.

I'm running Windows 10, Go version 1.5.1, Visual Studio Code 0.10.5 and Go extension 0.6.21. Was working fine before updating and I was using Go extension 0.6.17.

Problem is suggestions / intellisense works for internal package, but every external package I have no longer give suggestions when writing . or ctrl+space. Even net/http or core Go package does not work.

I wanted to try and run gocode myself to see what it's actually returning, so I've looked into the code for the extension and it is executing a child process similar to that: gocode -f=json autocomplete filename offset.

Not really sure how to get offset or what it represents, number of bytes for position that triggers the auto-complete? In any case, when I run this I got no output and I do not return to the prompt, I have to CTRL+C to return.

I'm unable to find anything interesting on Google either, probably wrongly searching or not exactly knowing what to search for.

Does someone would have an idea, goal of running gocode was to see if in fact the gocode was returning suggestion for external package than if yes, there's something with the extension.

If gocode does not returns anything, well it means it's not working properly now, anything I can do?

Thanks

Edit 1: Log from gocode following kostya answer

2015/12/23 07:26:11 Import path "github.com/gocraft/web" was not resolved
2015/12/23 07:26:11 Gocode's build context is:
2015/12/23 07:26:11  GOROOT: c:\go
2015/12/23 07:26:11  GOPATH:
2015/12/23 07:26:11  GOOS: windows
2015/12/23 07:26:11  GOARCH: amd64
2015/12/23 07:26:11  GBProjectRoot: ""
2015/12/23 07:26:11  lib-path: ""

It seems my GOPATH variable is not evaluated, but it's set, and when I run echo %GOPATH% I receive the correct value.

答案1

得分: 11

尝试在控制台中运行gocode服务器进程并观察输出:

gocode close
gocode -debug -s

确保您正在运行最新版本的gocode:

go get -u github.com/mdempsky/gocode

您可能希望运行以下命令来构建gocode(尽管我相信在这种情况下您将无法使用我建议的调试方法):

go get -u -ldflags -H=windowsgui github.com/mdempsky/gocode

如https://github.com/mdempsky/gocode中所建议的。

英文:

Try running gocode server process in the console and observe the output:

gocode close
gocode -debug -s

Make sure that you are running the latest version of gocode:

go get -u github.com/mdempsky/gocode

You might want to run the following command to build gocode instead (though I believe you won't be able to use debug method that I suggested in this case):

go get -u -ldflags -H=windowsgui github.com/mdempsky/gocode

as suggested at https://github.com/mdempsky/gocode

huangapple
  • 本文由 发表于 2015年12月23日 04:12:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/34423746.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定