精校:5.5

增加极客学院格式支持
This commit is contained in:
Unknwon
2015-07-18 22:37:48 +08:00
parent 2fbd044016
commit 4501794707
28 changed files with 44 additions and 20 deletions

18
README_gc.md Normal file
View File

@@ -0,0 +1,18 @@
# Go 入门指南
## 本书介绍
在接触 Go 语言之后,对这门编程语言非常着迷,期间也陆陆续续开始一些帮助国内编程爱好者了解和发展 Go 语言的工作,比如开始录制视频教程[《Go编程基础》](https://github.com/Unknwon/go-fundamental-programming)。但由于目前国内并没有比较好的 Go 语言书籍,而国外的优秀书籍因为英文的缘故在一定程度上也为不少 Go 语言爱好者带来了一些学习上的困扰,不仅为了加快扩散 Go 爱好者的国内群体,本人在完成阅读这本名叫 《The Way to Go》 之后,决定每天抽出一点时间来进行翻译的工作,并且以开源的形式免费分享给有需要的 Go 语言爱好者。
## 适用人群
适合有一定编程基础,初学 Go 语言的爱好者。
>
Martini&Macaron 交流群371440803
>
Golang 编程245386165
|更新日期 |更新内容
|----------|------------------
|2015-07-18|

0
TOC.md Normal file
View File

6
config.json Normal file
View File

@@ -0,0 +1,6 @@
{
"name": "Go 入门指南",
"introduction": "Go 经典书籍《The Way To Go》的中文译本。",
"content": "eBook",
"readme": "README_gc.md"
}

View File

@@ -4,7 +4,7 @@ Go 语言起源 2007 年,并于 2009 年正式对外发布。它从 2009 年 9
**这是一个由计算机领域 “发明之父” 所组成的黄金团队,他们对系统编程语言,操作系统和并行都有着非常深刻的见解**
![](images/1.1.designers_of_Go.jpg?raw=true)
![](../images/1.1.designers_of_Go.jpg?raw=true)
图 1.1 Go 语言设计者Griesemer、Thompson 和 Pike
@@ -34,7 +34,7 @@ Go 语言的官方网站是 [golang.org](http://golang.org),这个站点采用
Go 通过以下的 Logo 来展示它的速度并以囊地鼠Gopher作为它的吉祥物。
![](images/1.2.Go_logo.jpg?raw=true)
![](../images/1.2.Go_logo.jpg?raw=true)
图1.2 Go 语言 Logo

View File

@@ -12,7 +12,7 @@
下图展示了一些其它编程语言对 Go 语言的影响:
![](images/1.3.influences_on_go.jpg?raw=true)
![](../images/1.3.influences_on_go.jpg?raw=true)
图 1.3 其它编程语言对 Go 语言的影响

View File

@@ -26,7 +26,7 @@ Go 语言开发团队开发了适用于以下操作系统的编译器:
编译器目前支持以下基于 Intel 或 AMD 处理器架构的程序构建。
![](images/2.1.gc.jpg?raw=true)
![](../images/2.1.gc.jpg?raw=true)
图2.1 gc 编译器支持的处理器架构

View File

@@ -47,7 +47,7 @@
在完成编译之后(通常在 1 分钟以内,如果你在 B 型树莓派上编译,一般需要 1 个小时),你会在终端看到如下信息被打印:
![](images/2.3.allbash.png?raw=true)
![](../images/2.3.allbash.png?raw=true)
图 2.3 完成编译后在终端打印的信息

View File

@@ -29,7 +29,7 @@ LiteIDE 是一款非常好用的轻量级 Go 集成开发环境(基于 QT、Ka
同时,它具备了抽象语法树视图的功能,可以清楚地纵览项目中的常量、变量、函数、不同类型以及他们的属性和方法。
![](images/3.2.liteide.jpg?raw=true)
![](../images/3.2.liteide.jpg?raw=true)
图 3.1 LiteIDE 代码编辑界面和抽象语法树视图
@@ -39,7 +39,7 @@ LiteIDE 是一款非常好用的轻量级 Go 集成开发环境(基于 QT、Ka
其依附于著名的 Eclipse 这个大型开发环境,虽然需要安装 JVM 运行环境,但却可以很容易地享有 Eclipse 本身所具有的诸多功能。这是一个非常好的编辑器,完善的代码补全、抽象语法树视图、项目管理和程序调试功能。
![](images/3.2.goclipse.jpg?raw=true)
![](../images/3.2.goclipse.jpg?raw=true)
图 3.2 GoClipse 代码编辑界面、抽象语法树视图和项目管理

View File

@@ -147,13 +147,13 @@ func main() {
所有像 int、float、bool 和 string 这些基本类型都属于值类型,使用这些类型的变量直接指向存在内存中的值:
![](images/4.4.2_fig4.1.jpg?raw=true)
![](../images/4.4.2_fig4.1.jpg?raw=true)
另外,像数组(第 7 章)和结构(第 10 章)这些复合类型也是值类型。
当使用等号 `=` 将一个变量的值赋值给另一个变量时,如:`j = i`,实际上是在内存中将 i 的值进行了拷贝:
![](images/4.4.2_fig4.2.jpg?raw=true)
![](../images/4.4.2_fig4.2.jpg?raw=true)
你可以通过 &i 来获取变量 i 的内存地址(第 4.9 节例如0xf840000040每次的地址都可能不一样。值类型的变量的值存储在栈中。
@@ -163,7 +163,7 @@ func main() {
一个引用类型的变量 r1 存储的是 r1 的值所在的内存地址(数字),或内存地址中第一个字所在的位置。
![](images/4.4.2_fig4.3.jpg?raw=true)
![](../images/4.4.2_fig4.3.jpg?raw=true)
这个内存地址为称之为指针(你可以从上图中很清晰地看到,第 4.9 节将会详细说明),这个指针实际上也被存在另外的某一个字中。

View File

@@ -64,7 +64,7 @@ func main() {
我们可以用下图来表示内存使用的情况:
![](images/4.4.9_fig4.4.png?raw=true)
![](../images/4.4.9_fig4.4.png?raw=true)
程序 string_pointer.go 为我们展示了指针对string的例子。
@@ -95,7 +95,7 @@ func main() {
内存示意图如下:
![](images/4.4.9_fig4.5.png?raw=true)
![](../images/4.4.9_fig4.5.png?raw=true)
**注意事项**

View File

@@ -2,9 +2,9 @@
您可以使用 break 语句重写 for2.go 的代码:
Listing 5.10 [for3.go](examples/chapter_5/for3.go)
示例 5.10 [for3.go](examples/chapter_5/for3.go)
```
```go
for {
i = i - 1
fmt.Printf(The variable i is now: %d\n, i)
@@ -20,9 +20,9 @@ for {
下面的示例中包含了嵌套的循环体for4.gobreak 只会退出最内层的循环
Listing 5.11 [for4.go](examples/chapter_5/for4.go)
示例 5.11 [for4.go](examples/chapter_5/for4.go)
```
```go
package main
func main() {
@@ -44,9 +44,9 @@ func main() {
关键字 continue 忽略剩余的循环体而直接进入下一次循环的过程但不是无条件执行下一次循环执行之前依旧需要满足循环的判断条件
Listing 5.12 [for5.go](examples/chapter_5/for5.go)
示例 5.12 [for5.go](examples/chapter_5/for5.go)
```
```go
package main
func main() {
@@ -66,9 +66,9 @@ func main() {
0 1 2 3 4 6 7 8 9
```
5被跳过了
显然5 被跳过了
关键字 continue 只能被用于 for 循环中
另外关键字 continue 只能被用于 for 循环中
## 链接

View File

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB

View File

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 24 KiB

View File

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 94 KiB

View File

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 33 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 146 KiB

After

Width:  |  Height:  |  Size: 146 KiB

View File

Before

Width:  |  Height:  |  Size: 132 KiB

After

Width:  |  Height:  |  Size: 132 KiB

View File

Before

Width:  |  Height:  |  Size: 8.6 KiB

After

Width:  |  Height:  |  Size: 8.6 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 70 KiB

After

Width:  |  Height:  |  Size: 70 KiB

View File

Before

Width:  |  Height:  |  Size: 122 KiB

After

Width:  |  Height:  |  Size: 122 KiB

View File

Before

Width:  |  Height:  |  Size: 83 KiB

After

Width:  |  Height:  |  Size: 83 KiB

View File

Before

Width:  |  Height:  |  Size: 132 KiB

After

Width:  |  Height:  |  Size: 132 KiB