Skip to content

Commit 9062e8a

Browse files
authored
Merge pull request astaxie#788 from vCaesar/up10-pr
Update go install and fix set Go env
2 parents 5852747 + 910b23e commit 9062e8a

File tree

4 files changed

+48
-24
lines changed

4 files changed

+48
-24
lines changed

en/01.1.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ A 64-bit operating system will show the following:
7676

7777
### Mac
7878

79-
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.
79+
Go to the [download page](https://golang.org/dl/), choose `go1.4.2.darwin-386.pkg` (The later version has no 32-bit download.)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.
8080

8181
### Linux
8282

83-
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.
83+
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.
8484

8585
### Windows
8686

87-
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.
87+
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.
8888

8989
## Use third-party tools
9090

@@ -96,8 +96,8 @@ GVM is a Go multi-version control tool developed by a third-party, like rvm for
9696

9797
Then we install Go using the following commands:
9898

99-
gvm install go1.7.4
100-
gvm use go1.7.4
99+
gvm install go1.8
100+
gvm use go1.8
101101

102102
After the process has finished, you're all set.
103103

@@ -112,13 +112,16 @@ Ubuntu is the most popular desktop release version of Linux. It uses `apt-get` t
112112
###wget
113113
```sh
114114

115-
wget https://storage.googleapis.com/golang/go1.7.4.linux-amd64.tar.gz
116-
sudo tar -xzf go1.7.4.linux-amd64.tar.gz -C /usr/local
117-
export PATH=PATH:/usr/local/go/binexportGOROOT=HOME/go
118-
export PATH=PATH:GOROOT/bin
119-
export GOPATH=HOME/gowork
120-
```
115+
wget https://storage.googleapis.com/golang/go1.8.linux-amd64.tar.gz
116+
sudo tar -xzf go1.8.linux-amd64.tar.gz -C /usr/local
121117

118+
# Go environment
119+
export GOROOT=/usr/local/go
120+
export GOBIN=$GOROOT/bin
121+
export PATH=$PATH:$GOBIN
122+
export GOPATH=HOME/gopath
123+
```
124+
Starting from go 1.8,The GOPATH environment variable now has a default value if it is unset. It defaults to $HOME/go on Unix and %USERPROFILE%/go on Windows.
122125
### Homebrew
123126

124127
Homebrew is a software management tool commonly used in Mac to manage packages. Just type the following commands to install Go.

en/01.2.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
Go takes a unique approach to manage the code files with the introduction of a `$GOPATH` directory which contains all the go code in the machine. Note that this is different from the `$GOROOT` environment variable which states where go is installed on the machine. We have to define the $GOPATH variable before using the language, in *nix systems there is a file called `.bashrc` we need to append the below export statement to the file. The concept behind gopath is a novel one, where we can link to any go code at any instant of time without ambiguity.
66

7+
Starting from go 1.8,The GOPATH environment variable now has a default value if it is unset. It defaults to $HOME/go on Unix and %USERPROFILE%/go on Windows.
8+
79
In Unix-like systems, the variable should be used like this:
810

911
export GOPATH=/home/apple/mygo

zh/01.1.md

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Go 1.5彻底移除C代码,Runtime、Compiler、Linker均由Go编写,实现自
4646

4747
如果出现Go的Usage信息,那么说明Go已经安装成功了;如果出现该命令不存在,那么可以检查一下自己的PATH环境变中是否包含了Go的安装目录。
4848

49+
从go 1.8开始,GOPATH环境变量现在有一个默认值,如果它没有被设置。 它在Unix上默认为$HOME/go,在Windows上默认为%USERPROFILE%/go。
4950
> 关于上面的GOPATH将在下面小节详细讲解
5051
5152
## Go标准包安装
@@ -78,19 +79,19 @@ Linux系统用户可通过在Terminal中执行命令`arch`(即`uname -m`)来查
7879

7980
### Mac 安装
8081

81-
访问[下载地址][downlink],32位系统下载go1.4.2.darwin-386-osx10.8.pkg(最新版已无32位下载),64位系统下载go1.7.4.darwin-amd64.pkg,双击下载文件,一路默认安装点击下一步,这个时候go已经安装到你的系统中,默认已经在PATH中增加了相应的`~/go/bin`,这个时候打开终端,输入`go`
82+
访问[下载地址][downlink],32位系统下载go1.4.2.darwin-386-osx10.8.pkg(更新版已无32位下载),64位系统下载go1.8.darwin-amd64.pkg,双击下载文件,一路默认安装点击下一步,这个时候go已经安装到你的系统中,默认已经在PATH中增加了相应的`~/go/bin`,这个时候打开终端,输入`go`
8283

8384
看到类似上面源码安装成功的图片说明已经安装成功
8485

8586
如果出现go的Usage信息,那么说明go已经安装成功了;如果出现该命令不存在,那么可以检查一下自己的PATH环境变中是否包含了go的安装目录。
8687

8788
### Linux 安装
8889

89-
访问[下载地址][downlink],32位系统下载go1.7.4.linux-386.tar.gz,64位系统下载go1.7.4.linux-amd64.tar.gz,
90+
访问[下载地址][downlink],32位系统下载go1.8.linux-386.tar.gz,64位系统下载go1.8.linux-amd64.tar.gz,
9091

9192
假定你想要安装Go的目录为 `$GO_INSTALL_DIR`,后面替换为相应的目录路径。
9293

93-
解压缩`tar.gz`包到安装目录下:`tar zxvf go1.7.4.linux-amd64.tar.gz -C $GO_INSTALL_DIR`
94+
解压缩`tar.gz`包到安装目录下:`tar zxvf go1.8.linux-amd64.tar.gz -C $GO_INSTALL_DIR`
9495

9596
设置PATH,`export PATH=$PATH:$GO_INSTALL_DIR/go/bin`
9697

@@ -104,7 +105,7 @@ Linux系统用户可通过在Terminal中执行命令`arch`(即`uname -m`)来查
104105

105106
### Windows 安装 ###
106107

107-
访问[Google Code 下载页][downlink],32 位请选择名称中包含 windows-386 的 msi 安装包,64 位请选择名称中包含 windows-amd64 的。下载好后运行,不要修改默认安装目录 C:\Go\,若安装到其他位置会导致不能执行自己所编写的 Go 代码。安装完成后默认会在环境变量 Path 后添加 Go 安装目录下的 bin 目录 `C:\Go\bin\`,并添加环境变量 GOROOT,值为 Go 安装根目录 `C:\Go\`
108+
访问[Golang 下载页][downlink],32 位请选择名称中包含 windows-386 的 msi 安装包,64 位请选择名称中包含 windows-amd64 的。下载好后运行,不要修改默认安装目录 C:\Go\,若安装到其他位置会导致不能执行自己所编写的 Go 代码。安装完成后默认会在环境变量 Path 后添加 Go 安装目录下的 bin 目录 `C:\Go\bin\`,并添加环境变量 GOROOT,值为 Go 安装根目录 `C:\Go\`
108109

109110
**验证是否安装成功**
110111

@@ -124,11 +125,11 @@ gvm是第三方开发的Go多版本管理工具,类似ruby里面的rvm工具
124125
安装完成后我们就可以安装go了:
125126
```sh
126127

127-
gvm install go1.7.4
128-
gvm use go1.7.4
128+
gvm install go1.8
129+
gvm use go1.8
129130
```
130131
也可以使用下面的命令,省去每次调用gvm use的麻烦:
131-
gvm use go1.7.4 --default
132+
gvm use go1.8 --default
132133

133134
执行完上面的命令之后GOPATH、GOROOT等环境变量会自动设置好,这样就可以直接使用了。
134135

@@ -144,11 +145,28 @@ Ubuntu是目前使用最多的Linux桌面系统,使用`apt-get`命令来管理
144145
###wget
145146
```sh
146147
147-
wget https://storage.googleapis.com/golang/go1.7.4.linux-amd64.tar.gz
148-
sudo tar -xzf go1.7.4.linux-amd64.tar.gz -C /usr/local
149-
export PATH=PATH:/usr/local/go/binexportGOROOT=HOME/go
150-
export PATH=PATH:GOROOT/bin
151-
export GOPATH=HOME/gowork
148+
wget https://storage.googleapis.com/golang/go1.8.linux-amd64.tar.gz
149+
sudo tar -xzf go1.8.linux-amd64.tar.gz -C /usr/local
150+
```
151+
152+
配置环境变量:
153+
```sh
154+
155+
export GOROOT=/usr/local/go
156+
export GOBIN=$GOROOT/bin
157+
export PATH=$PATH:$GOBIN
158+
export GOPATH=HOME/gopath (可选设置)
159+
```
160+
或者使用:
161+
```sh
162+
sudo vim /etc/profile
163+
```
164+
并添加下面的内容:
165+
```sh
166+
export GOROOT=/usr/local/go
167+
export GOBIN=$GOROOT/bin
168+
export PATH=$PATH:$GOBIN
169+
export GOPATH=HOME/gopath (可选设置)
152170
```
153171

154172
### homebrew

zh/01.2.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# 1.2 GOPATH与工作空间
22

3-
前面我们在安装Go的时候看到需要设置GOPATH变量,Go从1.1版本开始必须设置这个变量,而且不能和Go的安装目录一样,这个目录用来存放Go源码,Go的可运行文件,以及相应的编译之后的包文件。所以这个目录下面有三个子目录:src、bin、pkg
3+
前面我们在安装Go的时候看到需要设置GOPATH变量,Go从1.1版本到1.7必须设置这个变量,而且不能和Go的安装目录一样,这个目录用来存放Go源码,Go的可运行文件,以及相应的编译之后的包文件。所以这个目录下面有三个子目录:src、bin、pkg
44

5+
从go 1.8开始,GOPATH环境变量现在有一个默认值,如果它没有被设置。 它在Unix上默认为$HOME/go,在Windows上默认为%USERPROFILE%/go。
56
## GOPATH设置
67
go 命令依赖一个重要的环境变量:$GOPATH
78

0 commit comments

Comments
 (0)