1. go语言开发环境

2. vim设置,Vundle安装,fatih/vim-go安装

3. gopls插件手动安装

 

1. 安装Go语言开发环境

参考:https://www.runoob.com/go/go-environment.html

安装包下载地址为:https://golang.org/dl/

如果打不开可以使用这个地址:https://golang.google.cn/dl/

1、下载二进制包:go1.4.linux-amd64.tar.gz (选择最新版就好)

2、将下载的二进制包解压至 /usr/local 目录。

3. 增加软链接

4、将 /usr/local/go/bin 目录添加至PATH环境变量:

然后重启一下XShell链接,应该就可以尝试 go version命令查看版本号了。

 

2. vim设置,Vundle配置。

1、下载Vundle源码

2、配置vimrc (这个是我自己的配置)

3、打开Vim,执行 :PluginInstall 即可

安装完成后,很多人会报错gopls的问题,解决方法在下面。

 

3. gopls插件手动安装

1、下载golang-tools源码

Ps. 源码地址在:https://github.com/golang/tools,只是因为下载太慢,所以用gitee复制了仓库。

所以每次下载的时候都需要同步一下远程仓库。

 

2. 使用 go install 命令尝试安装 gopls

 

P.s. 这里会有大量报错,我们依次来解决。

这里的意思是,缺少了这些源码文件。

如果我们用 go get 的话,它会自动下载这些文件,但是因为网络问题,还是会下载失败。没事,我们可以手动下载。

 

go get 设置方法点击这里就好。

 

步骤如下:

  1. 在github上找到这些源码并下载,并按对应的文件夹排列
  2. 重新执行 go install 命令安装gopls

 

P.S. 我的当前目录: ~/go/src

 

1. 安装 github.com/sergi/go-diff

源码地址在:https://github.com/sergi/go-diff ,因为它很小,所以很快就下载好了。

当然你现在可以执行一次 go install 命令,看看效果。

 

2. 安装 golang.org/x/mod

源码地址在:https://github.com/golang/mod

但是因为下载比较慢,所以克隆到了gitee.

地址是:https://gitee.com/tkxiong/golang-mod

 

3、安装golang.org/x/sync

源码地址在:https://github.com/golang/sync

克隆Gitee地址在:https://gitee.com/tkxiong/golang-sync

 

4、 安装golang.org/x/xerrors

源码地址在:https://github.com/golang/xerrors

克隆Gitee地址在:https://gitee.com/tkxiong/golang-xerrors

 

5、安装 honnef.co/go/tools

源码地址在:https://github.com/dominikh/go-tools

克隆Gitee地址在:https://gitee.com/tkxiong/honnef.co-go-tools

 

6. 安装 github.com/BurntSushi/toml

GitHub源地址:https://github.com/BurntSushi/toml

克隆Gitee地址:https://gitee.com/tkxiong/BurntSushi-toml

 

7、安装 mvdan.cc/xurls

GitHub源地址:https://github.com/mvdan/xurls

克隆Gitee地址:https://gitee.com/tkxiong/mvdan.cc-xurls

 

下载完之后,再执行,

没有报错,就是成功了。

 

go get使用不了的解决办法:

参考链接:https://www.sunzhongwei.com/problem-of-domestic-go-get-unable-to-download

七牛云的 go module 镜像。

参考 https://github.com/goproxy/goproxy.cn。

golang 1.13 可以直接执行:

然后再次使用 go get 下载 gin 依赖就可以了。为七牛云点个赞。

 

阿里云 Go Module 国内镜像仓库服务

除了七牛云,还可以使用阿里云的 golang 国内镜像。

https://mirrors.aliyun.com/goproxy/

设置方法

 

我用的第一种,亲测可用。

【Go】Ubuntu20 搭建go开发环境,安装Vundle,Vim-Go
Tagged on:     
0 0 投票数
Article Rating
订阅评论
提醒

0 评论
内联反馈
查看所有评论