英文:
autocomplete/intelliSense not working for golang in vscode
问题
我尝试了以下几件事情:
- 重新启动了VSCode。
- 从Google团队为VSCode安装了Go插件,并进行了卸载和重新安装。
- 在代码仓库中使用
go get golang.org/x/tools/gopls@latest
命令运行了gopls服务器。
英文:
I tried below things
- Restart of VSCode
- Uninstalled and installed Go plugin from google team for VSCode
- Ran gopls server in code repo using
go get golang.org/x/tools/gopls@latest
答案1
得分: 0
终于,我成功解决了这个问题。我的项目需要设置export CGO_LDFLAGS_ALLOW=".*"
环境变量。
所以,我在VSCode的Go插件的settings.json文件中添加了以下部分:
"go.toolsEnvVars": {
"CGO_LDFLAGS_ALLOW":".*"
}
之后,所有的模块都成功加载,并且VSCode能够提供智能感知功能。
英文:
Finally, I was able to solve this problem. My project was required export CGO_LDFLAGS_ALLOW=".*"
env var to be set.
So, I added below section to the settings.json of the Go plugin for vscode
"go.toolsEnvVars": {
"CGO_LDFLAGS_ALLOW":".*"
}
After that, all the modules were loaded successfully and VSCode was able to provide intelliSense.
答案2
得分: -1
有时候 vscode 无法检测到 GOPATH
和 GOROOT
,可以尝试在用户设置(JSON)中手动设置它们,像这样:
"go.gopath": "..路径..",
"go.goroot": "..路径..",
英文:
Sometimes vscode do not detect the GOPATH
and GOROOT
, try to set them manualy in the user settings (JSON) like so :
"go.gopath": "..path..",
"go.goroot": "..path..",
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论