Skip to content

Commit de3c5bd

Browse files
committed
Merging other languages
1 parent 380a8ee commit de3c5bd

File tree

490 files changed

+24543
-24592
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

490 files changed

+24543
-24592
lines changed

en/01.0.md

+20-23
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,20 @@
1-
# 1 GO环境配置
2-
3-
欢迎来到Go的世界,让我们开始探索吧!
4-
5-
Go是一种新的语言,一种并发的、带垃圾回收的、快速编译的语言。它具有以下特点:
6-
7-
- 它可以在一台计算机上用几秒钟的时间编译一个大型的Go程序。
8-
- Go为软件构造提供了一种模型,它使依赖分析更加容易,且避免了大部分C风格include文件与库的开头。
9-
- Go是静态类型的语言,它的类型系统没有层级。因此用户不需要在定义类型之间的关系上花费时间,这样感觉起来比典型的面向对象语言更轻量级。
10-
- Go完全是垃圾回收型的语言,并为并发执行与通信提供了基本的支持。
11-
- 按照其设计,Go打算为多核机器上系统软件的构造提供一种方法。
12-
13-
Go是一种编译型语言,它结合了解释型语言的游刃有余,动态类型语言的开发效率,以及静态类型的安全性。它也打算成为现代的,支持网络与多核计算的语言。要满足这些目标,需要解决一些语言上的问题:一个富有表达能力但轻量级的类型系统,并发与垃圾回收机制,严格的依赖规范等等。这些无法通过库或工具解决好,因此Go也就应运而生了。
14-
15-
在本章中,我们将讲述Go的安装方法,以及如何配置项目信息。
16-
17-
## 目录
18-
19-
![](images/navi1.png?raw=true)
20-
21-
## links
22-
* [目录](<preface.md>)
23-
* 下一节: [Go安装](<01.1.md>)
1+
# 1 Go Environment Configuration
2+
3+
Welcome to the world of Go, let's start exploring!
4+
5+
Go is a fast-compiled, garbage-collected, concurrent systems programming language. It has the following advantages:
6+
7+
- Compiles a large project within a few seconds.
8+
- Provides a software development model that is easy to reason about, avoiding most of the problems associated with C-style header files.
9+
- Is a static language that does not have levels in its type system, so users do not need to spend much time dealing with relations between types. It is more like a lightweight object-oriented language.
10+
- Performs garbage collection. It provides basic support for concurrency and communication.
11+
- Designed for multi-core computers.
12+
13+
Go is a compiled language. It combines the development efficiency of interpreted or dynamic languages with the security of static languages. It is going to be the language of choice for modern, multi-core computers with networking. For these purposes, there are some problems that need to inherently be resolved at the level of the language of choice, such as a richly expressive lightweight type system, a native concurrency model, and strictly regulated garbage collection. For quite some time, no packages or tools have emerged that have aimed to solve all of these problems in a pragmatic fashion; thus was born the motivation for the Go language.
14+
15+
In this chapter, I will show you how to install and configure your own Go development environment.
16+
17+
## Links
18+
19+
- [Directory](preface.md)
20+
- Next section: [Installation](01.1.md)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# 1 GO环境配置
2+
3+
欢迎来到Go的世界,让我们开始探索吧!
4+
5+
Go是一种新的语言,一种并发的、带垃圾回收的、快速编译的语言。它具有以下特点:
6+
7+
- 它可以在一台计算机上用几秒钟的时间编译一个大型的Go程序。
8+
- Go为软件构造提供了一种模型,它使依赖分析更加容易,且避免了大部分C风格include文件与库的开头。
9+
- Go是静态类型的语言,它的类型系统没有层级。因此用户不需要在定义类型之间的关系上花费时间,这样感觉起来比典型的面向对象语言更轻量级。
10+
- Go完全是垃圾回收型的语言,并为并发执行与通信提供了基本的支持。
11+
- 按照其设计,Go打算为多核机器上系统软件的构造提供一种方法。
12+
13+
Go是一种编译型语言,它结合了解释型语言的游刃有余,动态类型语言的开发效率,以及静态类型的安全性。它也打算成为现代的,支持网络与多核计算的语言。要满足这些目标,需要解决一些语言上的问题:一个富有表达能力但轻量级的类型系统,并发与垃圾回收机制,严格的依赖规范等等。这些无法通过库或工具解决好,因此Go也就应运而生了。
14+
15+
在本章中,我们将讲述Go的安装方法,以及如何配置项目信息。
16+
17+
## 目录
18+
19+
![](images/navi1.png?raw=true)
20+
21+
## links
22+
* [目录](<preface.md>)
23+
* 下一节: [Go安装](<01.1.md>)

en/01.1.md

+71-101
Original file line numberDiff line numberDiff line change
@@ -1,153 +1,123 @@
1-
# 1.1 Go 安装
1+
# 1.1 Installation
22

3-
## Go的三种安装方式
4-
Go有多种安装方式,你可以选择自己喜欢的。这里我们介绍三种最常见的安装方式:
3+
## Three ways to install Go
54

6-
- Go源码安装:这是一种标准的软件安装方式。对于经常使用Unix类系统的用户,尤其对于开发者来说,从源码安装可以自己定制。
7-
- Go标准包安装:Go提供了方便的安装包,支持Windows、Linux、Mac等系统。这种方式适合快速安装,可根据自己的系统位数下载好相应的安装包,一路next就可以轻松安装了。**推荐这种方式**
8-
- 第三方工具安装:目前有很多方便的第三方软件包工具,例如Ubuntu的apt-get、Mac的homebrew等。这种安装方式适合那些熟悉相应系统的用户。
5+
There are many ways to configure the Go development environment on your computer, and you can choose whichever one you like. The three most common ways are as follows.
96

10-
最后,如果你想在同一个系统中安装多个版本的Go,你可以参考第三方工具[GVM](https://github.com/moovweb/gvm),这是目前在这方面做得最好的工具,除非你知道怎么处理。
117

12-
## Go源码安装
13-
在Go的源代码中,有些部分是用Plan 9 C和AT&T汇编写的,因此假如你要想从源码安装,就必须安装C的编译工具。
8+
- Official installation packages.
9+
- The Go team provides convenient installation packages in Windows, Linux, Mac and other operating systems. This is probably the easiest way to get started.
10+
- Install it yourself from source code.
11+
- Popular with developers who are familiar with Unix-like systems.
12+
- Using third-party tools.
13+
- There are many third-party tools and package managers for installing Go, like apt-get in Ubuntu and homebrew for Mac.
14+
15+
In case you want to install more than one version of Go on a computer, you should take a look at a tool called [GVM](https://github.com/moovweb/gvm). It is the best tool I've seen so far for accomplishing this task, otherwise you'd have to deal with it yourself.
1416

15-
在Mac系统中,只要你安装了Xcode,就已经包含了相应的编译工具。
17+
## Install from source code
1618

17-
在类Unix系统中,需要安装gcc等工具。例如Ubuntu系统可通过在终端中执行`sudo apt-get install gcc libc6-dev`来安装编译工具。
19+
Because some parts of Go are written in Plan 9 C and AT&T assembler, you have to install a C compiler before taking the next step.
1820

19-
在Windows系统中,你需要安装MinGW,然后通过MinGW安装gcc,并设置相应的环境变量。
21+
On a Mac, if you have installed Xcode, you already have the compiler.
2022

21-
你可以直接去官网[下载源码](http://golang.org/dl/),找相应的`goVERSION.src.tar.gz`的文件下载,下载之后解压缩到`$HOME`目录,执行如下代码:
23+
On Unix-like systems, you need to install gcc or a similar compiler. For example, using the package manager apt-get (included with Ubuntu), one can install the required compilers as follows:
2224

23-
cd go/src
24-
./all.bash
25-
26-
运行all.bash后出现"ALL TESTS PASSED"字样时才算安装成功。
27-
28-
上面是Unix风格的命令,Windows下的安装方式类似,只不过是运行`all.bat`,调用的编译器是MinGW的gcc。
29-
30-
如果是Mac或者Unix用户需要设置几个环境变量,如果想重启之后也能生效的话把下面的命令写到`.bashrc`或者`.zshrc`里面,
31-
32-
export GOPATH=$HOME/gopath
33-
export PATH=$PATH:$HOME/go/bin:$GOPATH/bin
34-
35-
如果你是写入文件的,记得执行`bash .bashrc`或者`bash .zshrc`使得设置立马生效。
36-
37-
如果是window系统,就需要设置环境变量,在path里面增加相应的go所在的目录,设置gopath变量。
38-
39-
当你设置完毕之后在命令行里面输入`go`,看到如下图片即说明你已经安装成功
40-
41-
![](images/1.1.mac.png?raw=true)
25+
`sudo apt-get install gcc libc6-dev`
4226

43-
图1.1 源码安装之后执行Go命令的图
27+
On Windows, you need to install MinGW in order to install gcc. Don't forget to configure your environment variables after the installation has completed.( ***Everything that looks like this means it's commented by a translator: If you are using 64-bit Windows, you should install the 64-bit version of MinGW*** )
4428

45-
如果出现Go的Usage信息,那么说明Go已经安装成功了;如果出现该命令不存在,那么可以检查一下自己的PATH环境变中是否包含了Go的安装目录。
29+
The Go team uses [Mercurial](http://mercurial.selenic.com/downloads/) to manage their source code, so you need to install this tool in order to download the Go source code.
4630

47-
> 关于上面的GOPATH将在下面小节详细讲解
31+
At this point, execute the following commands to clone the Go source code and compile it.( ***It will clone the source code to your current directory. Switch your work path before you continue. This may take some time.*** )
4832

49-
## Go标准包安装
50-
51-
Go提供了每个平台打好包的一键安装,这些包默认会安装到如下目录:/usr/local/go (Windows系统:c:\Go),当然你可以改变他们的安装位置,但是改变之后你必须在你的环境变量中设置如下信息:
52-
53-
export GOROOT=$HOME/go
54-
export GOPATH=$HOME/gopath
55-
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin
56-
57-
上面这些命令对于Mac和Unix用户来说最好是写入`.bashrc`或者`.zshrc`文件,对于windows用户来说当然是写入环境变量。
58-
59-
### 如何判断自己的操作系统是32位还是64位?
60-
61-
我们接下来的Go安装需要判断操作系统的位数,所以这小节我们先确定自己的系统类型。
62-
63-
Windows系统用户请按Win+R运行cmd,输入`systeminfo`后回车,稍等片刻,会出现一些系统信息。在“系统类型”一行中,若显示“x64-based PC”,即为64位系统;若显示“X86-based PC”,则为32位系统。
64-
65-
Mac系统用户建议直接使用64位的,因为Go所支持的Mac OS X版本已经不支持纯32位处理器了。
33+
hg clone -u release https://code.google.com/p/go
34+
cd go/src
35+
./all.bash
36+
37+
A successful installation will end with the message "ALL TESTS PASSED."
6638

67-
Linux系统用户可通过在Terminal中执行命令`arch`(即`uname -m`)来查看系统信息:
39+
On Windows, you can achieve the same by running `all.bat`.
6840

69-
64位系统显示
41+
If you are using Windows, the installation package will set your environment variables automatically. In Unix-like systems, you need to set these variables manually as follows. ( ***If your Go version is greater than 1.0, you don't have to set $GOBIN, and it will automatically be related to your $GOROOT/bin, which we will talk about in the next section***)
7042

71-
x86_64
43+
export GOROOT=$HOME/go
44+
export GOBIN=$GOROOT/bin
45+
export PATH=$PATH:$GOROOT/bin
7246

73-
32位系统显示
47+
If you see the following information on your screen, you're all set.
7448

75-
i386
49+
![](images/1.1.mac.png?raw=true)
7650

77-
### Mac 安装
51+
Figure 1.1 Information after installing from source code
7852

79-
访问[下载地址][downlink],32位系统下载go1.4.2.darwin-386-osx10.8.pkg,64位系统下载go1.4.2.darwin-amd64-osx10.8.pkg,双击下载文件,一路默认安装点击下一步,这个时候go已经安装到你的系统中,默认已经在PATH中增加了相应的`~/go/bin`,这个时候打开终端,输入`go`
53+
Once you see the usage information of Go, it means you have successfully installed Go on your computer. If it says "no such command", check that your $PATH environment variable contains the installation path of Go.
8054

81-
看到类似上面源码安装成功的图片说明已经安装成功
55+
## Using the standard installation packages
8256

83-
如果出现go的Usage信息,那么说明go已经安装成功了;如果出现该命令不存在,那么可以检查一下自己的PATH环境变中是否包含了go的安装目录。
57+
Go has one-click installation packages for every supported operating system. These packages will install Go in `/usr/local/go` (`c:\Go` in Windows) by default. Of course this can be modified, but you also need to change all the environment variables manually as I've shown above.
8458

85-
### Linux 安装
59+
### How to check if your operating system is 32-bit or 64-bit?
8660

87-
访问[下载地址][downlink],32位系统下载go1.4.2.linux-386.tar.gz,64位系统下载go1.4.2.linux-amd64.tar.gz,
61+
Our next step depends on your operating system type, so we have to check it before we download the standard installation packages.
8862

89-
假定你想要安装Go的目录为 `$GO_INSTALL_DIR`,后面替换为相应的目录路径。
63+
If you are using Windows, press `Win+R` and then run the command tool. Type the `systeminfo` command and it will show you some useful system information. Find the line that says "system type" -if you see "x64-based PC" that means your operating system is 64-bit, 32-bit otherwise.
9064

91-
解压缩`tar.gz`包到安装目录下:`tar zxvf go1.4.2.linux-amd64.tar.gz -C $GO_INSTALL_DIR`
65+
I strongly recommend downloading the 64-bit package if you are a Mac user, as Go no longer supports pure 32-bit processors on Mac OSX.
9266

93-
设置PATH,`export PATH=$PATH:$GO_INSTALL_DIR/go/bin`
67+
Linux users can type `uname -a` in the terminal to see system information.
68+
A 64-bit operating system will show the following:
9469

95-
然后执行`go`
70+
<some description> x86_64 x86_64 x86_64 GNU/Linux
71+
// some machines such as Ubuntu 10.04 will show as following
72+
x86_64 GNU/Linux
9673

97-
![](images/1.1.linux.png?raw=true)
74+
32-bit operating systems instead show:
9875

99-
图1.2 Linux系统下安装成功之后执行go显示的信息
76+
<some description> i686 i686 i386 GNU/Linux
10077

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

103-
### Windows 安装 ###
80+
Go to the [download page](http://code.google.com/p/go/downloads/list), choose `go1.0.3.darwin-386.pkg` for 32-bit systems and `go1.0.3.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 igure 1.1.
10481

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

107-
**验证是否安装成功**
84+
Go to the [download page]((http://code.google.com/p/go/downloads/list), choose `go1.0.3.linux-386.tar.gz` for 32-bit systems and `go1.0.3.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.0.3.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.
10885

109-
在运行中输入 `cmd` 打开命令行工具,在提示符下输入 `go`,检查是否能看到 Usage 信息。输入 `cd %GOROOT%`,看是否能进入 Go 安装目录。若都成功,说明安装成功。
86+
### Windows
11087

111-
不能的话请检查上述环境变量 Path 和 GOROOT 的值。若不存在请卸载后重新安装,存在请重启计算机后重试以上步骤。
88+
Go to the [download page]((http://code.google.com/p/go/downloads/list), choose `go1.0.3.windows-386.msi` for 32-bit systems and `go1.0.3.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.
11289

113-
## 第三方工具安装
90+
## Use third-party tools
11491

11592
### GVM
11693

117-
gvm是第三方开发的Go多版本管理工具,类似ruby里面的rvm工具。使用起来相当的方便,安装gvm使用如下命令:
94+
GVM is a Go multi-version control tool developed by a third-party, like rvm for ruby. It's quite easy to use. Install gvm by typing the following commands in your terminal:
11895

119-
bash < <(curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer)
96+
bash < <(curl -s https://raw.github.com/moovweb/gvm/master/binscripts/gvm-installer)
12097

121-
安装完成后我们就可以安装go了:
98+
Then we install Go using the following commands:
12299

123-
gvm install go1.4.2
124-
gvm use go1.4.2
100+
gvm install go1.0.3
101+
gvm use go1.0.3
125102

126-
也可以使用下面的命令,省去每次调用gvm use的麻烦:
127-
gvm use go1.4.2 --default
128-
129-
执行完上面的命令之后GOPATH、GOROOT等环境变量会自动设置好,这样就可以直接使用了。
103+
After the process has finished, you're all set.
130104

131105
### apt-get
132-
Ubuntu是目前使用最多的Linux桌面系统,使用`apt-get`命令来管理软件包,我们可以通过下面的命令来安装Go,为了以后方便,应该把 `git` `mercurial` 也安装上:
133106

134-
sudo apt-get install python-software-properties
135-
sudo add-apt-repository ppa:gophers/go
136-
sudo apt-get update
137-
sudo apt-get install golang-stable git-core mercurial
107+
Ubuntu is the most popular desktop release version of Linux. It uses `apt-get` to manage packages. We can install Go using the following commands.
108+
109+
sudo add-apt-repository ppa:gophers/go
110+
sudo apt-get update
111+
sudo apt-get install golang-stable
138112

139-
### homebrew
140-
homebrew是Mac系统下面目前使用最多的管理软件的工具,目前已支持Go,可以通过命令直接安装Go,为了以后方便,应该把 `git` `mercurial` 也安装上:
113+
### Homebrew
141114

142-
brew update && brew upgrade
143-
brew install go
144-
brew install git
145-
brew install mercurial
115+
Homebrew is a software management tool commonly used in Mac to manage packages. Just type the following commands to install Go.
146116

117+
brew install go
147118

148-
## links
149-
* [目录](<preface.md>)
150-
* 上一节: [Go环境配置](<01.0.md>)
151-
* 下一节: [GOPATH 与工作空间](<01.2.md>)
119+
## Links
152120

153-
[downlink]:http://golang.org/dl/ "Go安装包下载"
121+
- [Directory](preface.md)
122+
- Previous section: [Go environment configuration](01.0.md)
123+
- Next section: [$GOPATH and workspace](01.2.md)

0 commit comments

Comments
 (0)