# 介绍

Mastering Go 第二版中文版来袭！

## 在线阅读

* 看云: <https://www.kancloud.cn/cloud001/golang>
* gitbook: <https://hantmac.gitbook.io/mastering-go-second/>

![](https://tva1.sinaimg.cn/large/00831rSTgy1gcravfqmndj306b07nq4g.jpg)

英文版第二版的 Mastering Go不知不觉上线了，<https://www.packtpub.com/programming/mastering-go-second-edition>

第一版在广大Golang爱好者的大力支持下已经完成release，我们开始第二版的翻译。

翻译规则目前先参考第一版，<https://github.com/hantmac/Mastering_Go_ZH_CN>

领取翻译章节的话，先起一个issue，表明领取的章节，然后给一个大致的DDL，及时同步翻译进展，以方便其他人了解进度。

项目刚刚启动，对初学者来说可以 强迫自己读一些英文原著，也是不错的学习机会；golang大佬也可以对翻译的效果给予指导。

有兴趣的可加入交流群，或者通过邮件沟通：<hantmac@outlook.com>（发邮件领取第二版英文电子版即可参与）

## 交流社区

有兴趣的读者可加golang交流群，大家一起交流。

关注公众号Go\_Official\_Blog 了解更多官方资讯。

![](https://tva1.sinaimg.cn/large/0081Kckwgy1gkix2xmoj3j305i05imxf.jpg)

## 翻译进度

*持续更新中。。。。*

* [目录](/mastering-go-second/master.md)
* [chapter 1 Go和操作系统](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.0.md)
  * [01.0 前言](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.0.md)
  * [01.1 Go的历史](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.1.md)
  * [01.2 Go的未来](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.2.md)
  * [01.3 Go的特性](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.3.md)
  * [01.3.1 Go是完美的吗](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.3.1.md)
  * [01.3.2 什么是预处理器](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.3.2.md)
  * [01.3.3 godoc](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.3.3.md)
  * [01.4 编译Go代码](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.4.md)
  * [01.5 执行Go代码](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.5.md)
  * [01.6 Go的两条规范](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.6.md)
  * [01.6.1 package 的导入规则](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.6.1.md)
  * [01.6.2 大括号的唯一位置](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/edit/master/eBook/chapter1/01.6.2.md)
  * [01.7 Go package 的下载](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/edit/master/eBook/chapter1/01.7.md)
  * [01.8 UNIX标准输入，标准输出，标准错误](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/edit/master/eBook/chapter1/01.8.md)
  * [01.9 关于print](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.9.md)
  * [01.10 使用标准输出](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.10.md)
  * [01.11 获取用户输入](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.11.md)
  * [01.11.1 关于:= 和 = ](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.11.1.md)
  * [01.11.2 从标准输入读取数据](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.11.2.md)
  * [01.11.3  操作命令行参数](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.11.2.md)
  * [01.12 错误输出](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.12.md)
  * [01.13 写入日志文件](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.13.md)
  * [01.13.1 日志级别](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.13.1.md)
  * [01.13.2 日志工具](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.13.2.md)
  * [01.13.3 日志服务器](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.13.3.md)
  * [01.13.4 发送到日志文件](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.13.4.md)
  * [01.13.5 关于log.Fatal()](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.13.5.md)
  * [01.13.6 关于log.panic()](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.13.6.md)
  * [01.13.7 写入指定的日志文件](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.13.7.md)
  * [01.13.8 日志中打印行号](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.13.8.md)
  * [01.14 Go的错误处理](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.14.md)
  * [01.14.1 错误类型](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.14.1.md)
  * [01.14.2 错误处理](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.14.2.md)
  * [01.15 使用Docker](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.15.md)
  * [01.16 更多练习](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.16.md)
  * [01.17 本章小结](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter1/01.17.md)
* [chapter 3 Go基本的数据类型](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.0.md)
  * [03.1 Go数值类型](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.1.md)
  * [03.1.1 整数](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.1.1.md)
  * [03.1.2 浮点数](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.1.2.md)
  * [03.1.3 复数](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.1.3.md)
  * [03.1.4 Go for循环](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.1.4.md)
  * [03.2 Go的循环](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.2.md)
  * [03.2.1  for](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.2.1.md)
  * [03.2.2 while](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.2.2.md)
  * [03.2.3 range](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.2.3.md)
  * [03.2.4 for 代码示例](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.2.4.md)
  * [03.3 数组](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.3.md)
  * [03.3.1 多维数组](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.3.1.md)
  * [03.3.2 Go数组的缺点](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.3.2.md)
  * [03.4 Go切片](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.4.md)
  * [03.4.1 切片的基本操作](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.4.1.md)
  * [03.4.2 切片的自动扩容](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.4.2.md)
  * [03.4.3 byte切片](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.4.3.md)
  * [03.4.4 copy()函数](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.4.4.md)
  * [03.4.5 多维切片](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.4.5.md)
  * [03.4.6 切片使用的代码示例](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.4.6.md)
  * [03.4.7 使用sort.slice()排序](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.4.7.md)
  * [03.4.8 为切片追加数组](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.4.8.md)
  * [03.5 Go map](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.5.md)
  * [03.5.1 map值为nil的坑](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.5.1.md)
  * [03.5.2 什么时候该用map](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.5.2.md)
  * [03.6 Go常量](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.6.md)
  * [03.6.1 常量生成器:iota](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.6.1.md)
  * [03.7 Go指针](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.7.md)
  * [03.7.1 为什么使用指针](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.7.1.md)
  * [03.8 时间与日期处理技巧](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.8.md)
  * [03.8.1 解析时间](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.8.1.md)
  * [03.8.2 解析时间的代码示例](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.8.2.md)
  * [03.8.3 解析日期](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.8.3.md)
  * [03.8.4 解析日期的代码示例](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.8.4.md)
  * [03.8.5 格式化时间与日期](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.8.5.md)
  * [03.8.6 测量执行时间](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.8.6.md)
  * [03.8.7 测量Go的垃圾回收速度](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.8.7.md)
  * [03.9 有用的链接和练习](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.9.md)
  * [03.10 本章小结](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter3/03.10.md)
* [chapter 9 并发-goroutine，channel和pipelines](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter9/09.0.md)
  * [09.1 关于进程，线程与goroutine](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter9/09.1.md)
  * [09.1.1 Go scheduler](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter9/09.1.1.md)
  * [09.1.2 并发与并行](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter9/09.1.2.md)
  * [09.2 goroutine](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter9/09.2.md)
  * [09.2.1 创建goroutine](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter9/09.2.1.md)
  * [09.2.2创建多个goroutine](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter9/09.2.2.md)
  * [09.3 优雅地结束goroutine](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter9/09.3.md)
  * [09.3.1 当Add()和Done()的数量不匹配时会发生什么？](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter9/09.3.1.md)
  * [09.4 channel](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter9/09.4.md)
  * [09.4.1 往通道中写入](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter9/09.4.1.md)
  * [09.4.2 从通道中接收](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter9/09.4.2.md)
  * [09.4.3 从关闭的channel中读数据会发生什么](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter9/09.4.3.md)
  * [09.4.4 通道作为函数参数传递](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter9/09.4.4.md)
  * [09.5 管道](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter9/09.5.md)
  * [09.6 竟态条件](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter9/09.6.md)
  * [09.7 比较Go和Rust的并发模型](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter9/09.7.md)
  * [09.8 比较Go和Erlang的并发模型](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter9/09.8.md)
  * [09.9 其他学习资源](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter9/09.9.md)
  * [09.10 练习题](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter9/09.10.md)
  * [09.11 本章小结](https://github.com/hantmac/Mastering_Go_Second_Edition_Zh_CN/blob/master/eBook/chapter9/09.11.md)

## 规则&\&Fork&\&PR

* 章节命名规则：举例，第一章第一节，01.1.md,如果第一节下面还有分支，01.1.1,依次类推;
* 联系邮箱，取得电子版，获得安排的翻译章节，Fork分支，提交PR;
* 由多人审核后，合并

## 致谢

* 本书原作者：Mihalis Tsoukalos
* 参与翻译人员
  * [Jeremy](https://github.com/hantmac)
  * [calmbryan](https://github.com/calmbryan)
  * [newlife](https://github.com/newlife)

## 授权许可

除特别声明外，本书中的内容使用 [CC BY-SA 3.0 License](http://creativecommons.org/licenses/by-sa/3.0/)（创作共用 署名-相同方式共享3.0 许可协议）授权，代码遵循 [BSD 3-Clause License](https://github.com/astaxie/build-web-application-with-golang/blob/master/LICENSE.md)（3 项条款的 BSD 许可协议）。

## Go学习资料及社区（持续更新中。。。）

* [Go By Example 英文网站](https://gobyexample.com/)
* [Go By Example 中文网站](https://books.studygolang.com/gobyexample/)
* [GOCN Forum](https://gocn.vip/)
* [Go语言中文网](https://studygolang.com/)
* [Go walker 强大的Go在线API文档](https://gowalker.org/)
* [jsonTOGo 好用的json转go struct工具](https://mholt.github.io/json-to-go/)
* [Go web框架beego](https://beego.me/)
* [官方代码规范指导](https://github.com/golang/go/wiki/CodeReviewComments)
* [xorm](https://github.com/go-xorm/xorm)支持 MySQL、PostgreSQL、SQLite3 以及 MsSQL
* [mgo](http://labix.org/mgo)MongoDB 官方推荐驱动
* [gorm](https://github.com/jinzhu/gorm)全功能 ORM (无限接近) 支持 MySQL、PostgreSQL、SQLite3 以及 MsSQL


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://hantmac.gitbook.io/mastering-go-second/master.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
