我开始使用Go,并且想使用Visual Studio Code进行编辑。我已经在Ubuntu计算机上成功安装了go。
我的GOPATH
(进入环境)在settings.json中设置为与go.gopath
相同的值。如果我运行Go: Current GOPATH
,它将输出正确的路径。
但是,我无法安装go扩展程序。如果单击Install all
,将得到类似以下的输出:
Installing 1 tool at home/jan/go/bin
dlv
Installing github.com/go-delve/delve/cmd/dlv FAILED
1 tools failed to install.
dlv:
Error: Command failed: /snap/bin/go get -u -v github.com/go-delve/delve/cmd/dlv
我似乎只能使用/snap/bin/go get -u -v github.com/go-delve/delve/cmd/dlv
手动安装软件包。该命令运行没有错误,但是VSCode似乎找不到dlv。
我的settings.json:
{
"terminal.integrated.rendererType": "dom",
"go.useLanguageServer": true,
"go.formatTool": "gofmt",
"go.lintOnSave": "file",
"go.vetOnSave": "package",
"go.buildOnSave": "package",
"go.lintTool": "golint",
"go.gopath": "home/jan/go"
}
我在计算机上安装了git。它没有问题。
答案 0 :(得分:2)
Your GOPATH is not set correctly in settings.json
.
"go.gopath": "home/jan/go"
This path is relative, and so it would be appended to whatever your working directory is, with the obvious result of not being able to find the path as it won't exist.
You can either set it correctly, or delete it and the GOPATH environment variable will be used. (I run it this way.)
"go.gopath": "/home/jan/go"