Go_Study

Linux安装Go

apt方式

1
2
3
4
sudo apt install python-software-properties
sudo add-apt-repository ppa:gophers/go
sudo apt update
sudo apt install golang-stable git-core mercurial

wget源码方式

官方下载地址
wget https://dl.google.com/go/go1.10.3.linux-amd64.tar.gz
sudo tar -xzf go1.10.3.linux-amd64.tar.gz -C /usr/local/share

配置用户环境变量:
vi ~/.bashrc

1
2
3
4
export GOROOT=/usr/local/share/go
export GOBIN=$GOROOT/bin
export PATH=$PATH:$GOBIN
export GOPATH=$HOME/Applications/Go (可选设置)

添加Linux:
sudo vim /etc/profile
并添加下面的内容:

1
2
3
4
export GOROOT=/usr/local/share/go
export GOBIN=$GOROOT/bin
export PATH=$PATH:$GOBIN
export GOPATH=$HOME/Applications/Go (可选设置)

重载profile文件
source /etc/profile

0%