Linux 安装 golang 和 dep (附错两个误解决方法)
sxwxs · · 1849 次点击 · · 开始浏览安装 Go
下载
在这里找想要安装的版本: https://golang.google.cn/dl/
我下载了 1.13.7:
wget https://dl.google.com/go/go1.13.7.linux-amd64.tar.gz
解压安装
tar -C /usr/local -xzf go1.13.7.linux-amd64.tar.gz
这一步需要 root 权限,非 root 用户要加 sudo
sudo tar -C /usr/local -xzf go1.13.7.linux-amd64.tar.gz
配置环境变量
编辑 profile 文件
sudo vi /etc/profile
在文件末尾添加
export PATH=$PATH:/usr/local/go/bin
立即生效需要执行: source /etc/profile
安装 dep
方法一 通过二进制安装包安装
mkdir -p go/bin
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
方法二 go get 安装
go get -u github.com/golang/dep/cmd/dep
方法三 直接下载
方法一、方法二都太慢了
https://github.com/golang/dep/releases/
直接到 github 的 release 页面下载,
wget https://github.com/golang/dep/releases/download/v0.5.4/dep-linux-amd64
下载完了添加可执行权限移动到 /usr/local/go/bin 目录下,再重命名为 dep 就好了
chmod +x dep-linux-amd64
mv dep-linux-amd64 /usr/local/go/bin/dep
错误解决
Installation requires your GOBIN directory /root/go/bin to exist. Please create it.
按照教程直接操作是不行的
[root@zrcq7d8itgvcrhkq-1130695 ~]# curl https://raw.githubusercontent... | sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 5230 100 5230 0 0 1982 0 0:00:02 0:00:02 --:--:-- 1982
ARCH = amd64
OS = linux
Installation requires your GOBIN directory /root/go/bin to exist. Please create it.
这个错误说明你没有 go/bin 目录,先执行 mkdir -p go/bin 就好了
curl: (7) Failed connect to raw.githubusercontent.com:443; Connection refused
网络问题,多试几次或者使用方法二
参考资料
https://golang.google.cn/doc/install
https://golang.github.io/dep/docs/installation.html
欢迎来我的博客: https://codeplot.top/
有疑问加站长微信联系(非本文作者)
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
关注微信- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码` - 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传
收入到我管理的专栏 新建专栏
安装 Go
下载
在这里找想要安装的版本: https://golang.google.cn/dl/
我下载了 1.13.7:
wget https://dl.google.com/go/go1.13.7.linux-amd64.tar.gz
解压安装
tar -C /usr/local -xzf go1.13.7.linux-amd64.tar.gz
这一步需要 root 权限,非 root 用户要加 sudo
sudo tar -C /usr/local -xzf go1.13.7.linux-amd64.tar.gz
配置环境变量
编辑 profile 文件
sudo vi /etc/profile
在文件末尾添加
export PATH=$PATH:/usr/local/go/bin
立即生效需要执行: source /etc/profile
安装 dep
方法一 通过二进制安装包安装
mkdir -p go/bin
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
方法二 go get 安装
go get -u github.com/golang/dep/cmd/dep
方法三 直接下载
方法一、方法二都太慢了
https://github.com/golang/dep/releases/
直接到 github 的 release 页面下载,
wget https://github.com/golang/dep/releases/download/v0.5.4/dep-linux-amd64
下载完了添加可执行权限移动到 /usr/local/go/bin 目录下,再重命名为 dep 就好了
chmod +x dep-linux-amd64
mv dep-linux-amd64 /usr/local/go/bin/dep
错误解决
Installation requires your GOBIN directory /root/go/bin to exist. Please create it.
按照教程直接操作是不行的
[root@zrcq7d8itgvcrhkq-1130695 ~]# curl https://raw.githubusercontent... | sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 5230 100 5230 0 0 1982 0 0:00:02 0:00:02 --:--:-- 1982
ARCH = amd64
OS = linux
Installation requires your GOBIN directory /root/go/bin to exist. Please create it.
这个错误说明你没有 go/bin 目录,先执行 mkdir -p go/bin 就好了
curl: (7) Failed connect to raw.githubusercontent.com:443; Connection refused
网络问题,多试几次或者使用方法二
参考资料
https://golang.google.cn/doc/install
https://golang.github.io/dep/docs/installation.html
欢迎来我的博客: https://codeplot.top/