diff --git a/en/01.1.md b/en/01.1.md index 681eb2b4..11bbb795 100644 --- a/en/01.1.md +++ b/en/01.1.md @@ -121,7 +121,7 @@ export GOBIN=$GOROOT/bin export PATH=$PATH:$GOBIN export GOPATH=HOME/gopath ``` - +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. ### Homebrew Homebrew is a software management tool commonly used in Mac to manage packages. Just type the following commands to install Go. diff --git a/en/01.2.md b/en/01.2.md index e927e21e..d1260864 100644 --- a/en/01.2.md +++ b/en/01.2.md @@ -4,6 +4,8 @@ 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. +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. + In Unix-like systems, the variable should be used like this: export GOPATH=/home/apple/mygo diff --git a/zh/01.1.md b/zh/01.1.md index 23753f7c..521ec0b9 100644 --- a/zh/01.1.md +++ b/zh/01.1.md @@ -46,6 +46,7 @@ Go 1.5彻底移除C代码,Runtime、Compiler、Linker均由Go编写,实现自 如果出现Go的Usage信息,那么说明Go已经安装成功了;如果出现该命令不存在,那么可以检查一下自己的PATH环境变中是否包含了Go的安装目录。 +从go 1.8开始,GOPATH环境变量现在有一个默认值,如果它没有被设置。 它在Unix上默认为$HOME/go,在Windows上默认为%USERPROFILE%/go。 > 关于上面的GOPATH将在下面小节详细讲解 ## Go标准包安装 @@ -154,7 +155,7 @@ sudo tar -xzf go1.8.linux-amd64.tar.gz -C /usr/local export GOROOT=/usr/local/go export GOBIN=$GOROOT/bin export PATH=$PATH:$GOBIN -export GOPATH=HOME/gopath +export GOPATH=HOME/gopath (可选设置) ``` 或者使用: ```sh @@ -165,7 +166,7 @@ sudo vim /etc/profile export GOROOT=/usr/local/go export GOBIN=$GOROOT/bin export PATH=$PATH:$GOBIN -export GOPATH=HOME/gopath +export GOPATH=HOME/gopath (可选设置) ``` ### homebrew diff --git a/zh/01.2.md b/zh/01.2.md index 5c708666..abe528bf 100644 --- a/zh/01.2.md +++ b/zh/01.2.md @@ -1,7 +1,8 @@ # 1.2 GOPATH与工作空间 -前面我们在安装Go的时候看到需要设置GOPATH变量,Go从1.1版本开始必须设置这个变量,而且不能和Go的安装目录一样,这个目录用来存放Go源码,Go的可运行文件,以及相应的编译之后的包文件。所以这个目录下面有三个子目录:src、bin、pkg +前面我们在安装Go的时候看到需要设置GOPATH变量,Go从1.1版本到1.7必须设置这个变量,而且不能和Go的安装目录一样,这个目录用来存放Go源码,Go的可运行文件,以及相应的编译之后的包文件。所以这个目录下面有三个子目录:src、bin、pkg +从go 1.8开始,GOPATH环境变量现在有一个默认值,如果它没有被设置。 它在Unix上默认为$HOME/go,在Windows上默认为%USERPROFILE%/go。 ## GOPATH设置 go 命令依赖一个重要的环境变量:$GOPATH