vscode 、codeserver安装go扩展的错误

vscode 、codeserver安装go扩展的错误

大概出现这样的错误

1
2
3
gopls: failed to install gopls(golang.org/x/tools/gopls@latest): Error: Command failed: /opt/go/bin/go install -v golang.org/x/tools/gopls@latest

build cache is required, but could not be located: GOCACHE is not defined and neither $XDG_CACHE_HOME nor $HOME are defined

这个错误基本上出现在codeserver上

手动安装即可

和 go-outline相关的8个

1
2
3
4
5
6
7
8
go install -v github.com/cweill/gotests/gotests@latest
go install -v github.com/fatih/gomodifytags@latest
go install -v github.com/josharian/impl@latest
go install -v github.com/haya14busa/goplay/cmd/goplay@latest
go install -v github.com/go-delve/delve/cmd/dlv@latest
go install -v honnef.co/go/tools/cmd/staticcheck@latest
go install -v golang.org/x/tools/gopls@latest
go install -v github.com/ramya-rao-a/go-outline@latest

和gopls相关的7个,和前面的8个多数重复的

1
2
3
4
5
6
7
go install -v github.com/cweill/gotests/gotests@latest
go install -v github.com/fatih/gomodifytags@latest
go install -v github.com/josharian/impl@latest
go install -v github.com/haya14busa/goplay/cmd/goplay@lates
go install -v github.com/go-delve/delve/cmd/dlv@latest
go install -v honnef.co/go/tools/cmd/staticcheck@latest
go install -v golang.org/x/tools/gopls@latest

另外一个编译的插件 id golang.Go

命令行执行完成上面的命令后,重启 codeserver

如果 codeserver提示 build cache is required, but could not be located: GOCACHE is not defined and neither $XDG_CACHE_HOME nor $HOME are defined 那么 先创建对应目录,然后 编辑 /etc/profile 文末添加 如果你用了其他环境变量配置文件,建议都挪到这个一个文件里面

1
2
3
4
5
6
export GO111MODULE=on
export GOROOT=/opt/go
export GOPATH=/opt/gopath
export GOCACHE=/opt/gocache
export GOPROXY=https://proxy.golang.com.cn,direct
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

然后

1
source /etc/profile

再重启 codeserver测试 如果还是不行,重启一下整机就好了。 另外,启动的时候,打开一个小的项目文件,不要打开太大太复杂的项目文件

相关内容

1、安装 vscode online codeserver

2、codeserver配置go开发环境的错误

3、code Server url参数 打开指定的工作区或者文件夹

4、 ubuntu22.04.1LTS安装golang最新版本

Licensed under CC BY-NC-SA 4.0
comments powered by Disqus
使用 Hugo 构建
主题 StackJimmy 设计