在VSCode上启动go模块时,系统提示我安装一些工具
在vscode终端中的日志下方,选择安装安装失败
VSCODE一直对我大喊“无法安装”的东西,仅仅是因为忽略了我的路径 如下所示
Tools environment: GOPATH=/home/go
Installing 1 tool at /home/go/bin in module mode.
gopls
Installing golang.org/x/tools/gopls FAILED
1 tools failed to install.
gopls: failed to install gopls(golang.org/x/tools/gopls): Error: Command failed: /usr/local/go/bin/go get -v golang.org/x/tools/gopls
go: writing stat cache: mkdir /home/go: permission denied
go: downloading golang.org/x/tools/gopls v0.5.1
go: downloading golang.org/x/tools v0.0.0-20201017001424-6003fad69a88
go get golang.org/x/tools/gopls: mkdir /home/go: permission denied
undefined
这些是我的GOPATH
和GOROOT
# GOLANG
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
export PATH=$GOPATH/bin:$PATH
export PATH=$GOROOT/bin:$PATH
这是我的vscode settings.json
{
"[dart]": {
"editor.formatOnSave": true,
"editor.formatOnType": true,
"editor.rulers": [
80
],
"editor.selectionHighlight": false,
"editor.suggest.snippetsPreventQuickSuggestions": false,
"editor.suggestSelection": "first",
"editor.tabCompletion": "onlySnippets",
"editor.wordBasedSuggestions": false
},
"workbench.iconTheme": "material-icon-theme",
"workbench.colorTheme": "One Dark Pro",
"dart.sdkPath": "/home/francesco/development/dart",
"dart.openDevTools": "flutter",
"go.formatTool": "goimports",
"dart.checkForSdkUpdates": false,
"go.useLanguageServer": true,
"go.inferGopath": false,
"go.gopath": "/home/go",
"go.goroot": "/usr/local/go"
}
我应该采取什么措施来纠正错误?
答案 0 :(得分:1)
您的错误是:
go: writing stat cache: mkdir /home/go: permission denied
Go尝试写入/home/go
。此文件夹源自:
export GOPATH=$HOME/go
因此,看来您的$HOME
没有指向您的主文件夹。 GOPATH
应该指向您具有写许可权的文件夹,因为模块缓存位于GOPATH
下。因此,它应指向用户主目录下的文件夹,例如/home/francesco/go
。