Update install and fix Go env

This commit is contained in:
vCaesar
2017-02-17 21:19:48 +08:00
parent 349b1fdc97
commit 0a68b5c3e5
2 changed files with 41 additions and 21 deletions

View File

@@ -76,15 +76,15 @@ A 64-bit operating system will show the following:
### Mac
Go to the [download page](https://golang.org/dl/), choose `go1.4.2.darwin-386.pkg` for 32-bit systems and `go1.7.4.darwin-amd64.pkg` for 64-bit systems. Going all the way to the end by clicking "next", `~/go/bin` will be added to your system's $PATH after you finish the installation. Now open the terminal and type `go`. You should see the same output shown in figure 1.1.
Go to the [download page](https://golang.org/dl/), choose `go1.4.2.darwin-386.pkg` for 32-bit systems and `go1.8.darwin-amd64.pkg` for 64-bit systems. Going all the way to the end by clicking "next", `~/go/bin` will be added to your system's $PATH after you finish the installation. Now open the terminal and type `go`. You should see the same output shown in figure 1.1.
### Linux
Go to the [download page](https://golang.org/dl/), choose `go1.7.4.linux-386.tar.gz` for 32-bit systems and `go1.7.4.linux-amd64.tar.gz` for 64-bit systems. Suppose you want to install Go in the `$GO_INSTALL_DIR` path. Uncompress the `tar.gz` to your chosen path using the command `tar zxvf go1.7.4.linux-amd64.tar.gz -C $GO_INSTALL_DIR`. Then set your $PATH with the following: `export PATH=$PATH:$GO_INSTALL_DIR/go/bin`. Now just open the terminal and type `go`. You should now see the same output displayed in figure 1.1.
Go to the [download page](https://golang.org/dl/), choose `go1.8.linux-386.tar.gz` for 32-bit systems and `go1.8.linux-amd64.tar.gz` for 64-bit systems. Suppose you want to install Go in the `$GO_INSTALL_DIR` path. Uncompress the `tar.gz` to your chosen path using the command `tar zxvf go1.8.linux-amd64.tar.gz -C $GO_INSTALL_DIR`. Then set your $PATH with the following: `export PATH=$PATH:$GO_INSTALL_DIR/go/bin`. Now just open the terminal and type `go`. You should now see the same output displayed in figure 1.1.
### Windows
Go to the [download page](https://golang.org/dl/), choose `go1.7.4.windows-386.msi` for 32-bit systems and `go1.7.4.windows-amd64.msi` for 64-bit systems. Going all the way to the end by clicking "next", `c:/go/bin` will be added to `path`. Now just open a command line window and type `go`. You should now see the same output displayed in figure 1.1.
Go to the [download page](https://golang.org/dl/), choose `go1.8.windows-386.msi` for 32-bit systems and `go1.8.windows-amd64.msi` for 64-bit systems. Going all the way to the end by clicking "next", `c:/go/bin` will be added to `path`. Now just open a command line window and type `go`. You should now see the same output displayed in figure 1.1.
## Use third-party tools
@@ -96,8 +96,8 @@ GVM is a Go multi-version control tool developed by a third-party, like rvm for
Then we install Go using the following commands:
gvm install go1.7.4
gvm use go1.7.4
gvm install go1.8
gvm use go1.8
After the process has finished, you're all set.
@@ -112,11 +112,14 @@ Ubuntu is the most popular desktop release version of Linux. It uses `apt-get` t
###wget
```sh
wget https://storage.googleapis.com/golang/go1.7.4.linux-amd64.tar.gz
sudo tar -xzf go1.7.4.linux-amd64.tar.gz -C /usr/local
export PATH=PATH:/usr/local/go/binexportGOROOT=HOME/go
export PATH=PATH:GOROOT/bin
export GOPATH=HOME/gowork
wget https://storage.googleapis.com/golang/go1.8.linux-amd64.tar.gz
sudo tar -xzf go1.8.linux-amd64.tar.gz -C /usr/local
# Go environment
export GOROOT=/usr/local/go
export GOBIN=$GOROOT/bin
export PATH=$PATH:$GOBIN
export GOPATH=HOME/gopath
```
### Homebrew

View File

@@ -78,7 +78,7 @@ Linux系统用户可通过在Terminal中执行命令`arch`(即`uname -m`)来查
### Mac 安装
访问[下载地址][downlink]32位系统下载go1.4.2.darwin-386-osx10.8.pkg(最新版已无32位下载)64位系统下载go1.7.4.darwin-amd64.pkg双击下载文件一路默认安装点击下一步这个时候go已经安装到你的系统中默认已经在PATH中增加了相应的`~/go/bin`,这个时候打开终端,输入`go`
访问[下载地址][downlink]32位系统下载go1.4.2.darwin-386-osx10.8.pkg(最新版已无32位下载)64位系统下载go1.8.darwin-amd64.pkg双击下载文件一路默认安装点击下一步这个时候go已经安装到你的系统中默认已经在PATH中增加了相应的`~/go/bin`,这个时候打开终端,输入`go`
看到类似上面源码安装成功的图片说明已经安装成功
@@ -86,11 +86,11 @@ Linux系统用户可通过在Terminal中执行命令`arch`(即`uname -m`)来查
### Linux 安装
访问[下载地址][downlink]32位系统下载go1.7.4.linux-386.tar.gz64位系统下载go1.7.4.linux-amd64.tar.gz
访问[下载地址][downlink]32位系统下载go1.8.linux-386.tar.gz64位系统下载go1.8.linux-amd64.tar.gz
假定你想要安装Go的目录为 `$GO_INSTALL_DIR`,后面替换为相应的目录路径。
解压缩`tar.gz`包到安装目录下:`tar zxvf go1.7.4.linux-amd64.tar.gz -C $GO_INSTALL_DIR`
解压缩`tar.gz`包到安装目录下:`tar zxvf go1.8.linux-amd64.tar.gz -C $GO_INSTALL_DIR`
设置PATH`export PATH=$PATH:$GO_INSTALL_DIR/go/bin`
@@ -124,11 +124,11 @@ gvm是第三方开发的Go多版本管理工具类似ruby里面的rvm工具
安装完成后我们就可以安装go了
```sh
gvm install go1.7.4
gvm use go1.7.4
gvm install go1.8
gvm use go1.8
```
也可以使用下面的命令省去每次调用gvm use的麻烦
gvm use go1.7.4 --default
gvm use go1.8 --default
执行完上面的命令之后GOPATH、GOROOT等环境变量会自动设置好这样就可以直接使用了。
@@ -144,11 +144,28 @@ Ubuntu是目前使用最多的Linux桌面系统使用`apt-get`命令来管理
###wget
```sh
wget https://storage.googleapis.com/golang/go1.7.4.linux-amd64.tar.gz
sudo tar -xzf go1.7.4.linux-amd64.tar.gz -C /usr/local
export PATH=PATH:/usr/local/go/binexportGOROOT=HOME/go
export PATH=PATH:GOROOT/bin
export GOPATH=HOME/gowork
wget https://storage.googleapis.com/golang/go1.8.linux-amd64.tar.gz
sudo tar -xzf go1.8.linux-amd64.tar.gz -C /usr/local
```
配置环境变量:
```sh
export GOROOT=/usr/local/go
export GOBIN=$GOROOT/bin
export PATH=$PATH:$GOBIN
export GOPATH=HOME/gopath
```
或者使用:
```sh
sudo vim /etc/profile
```
并添加下面的内容:
```sh
export GOROOT=/usr/local/go
export GOBIN=$GOROOT/bin
export PATH=$PATH:$GOBIN
export GOPATH=HOME/gopath
```
### homebrew