# Mastering_Go_Second_Edition_Zh_CN
Mastering Go 第二版中文版來襲!

-----
英文版第二版的 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 了解更多官方資訊(公眾號中回復`加群`即可)。

-----
### 翻譯進度
*持續更新中。。。。*
- [目錄]()
- [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
- 介紹
- 1 Go與操作系統
- 01.1 Go的歷史
- 01.2 Go的未來
- 01.3 Go的優點
- 01.3.1 Go是完美的么
- 01.3.2 什么是預處理器
- 01.3.3 godoc
- 01.4 編譯Go代碼
- 2 理解 Go 的內部構造
- Go 編譯器
- Go 的垃圾回收
- 三色算法
- 有關 Go 垃圾收集器操作的更多信息
- Maps, silces 與 Go 垃圾回收器
- Unsafe code
- 有關 unsafe 包
- 另一個 usafe 包的例子
- 從 Go 調用 C 代碼
- 在同一文件用 Go 調用 C 代碼
- 在單獨的文件用 Go 調用 C 代碼
- 從 C 調用 Go 代碼
- Go 包
- C 代碼
- defer 關鍵字
- 用 defer 打印日志
- Panic 和 Recover
- 單獨使用 Panic 函數
- 兩個好用的 UNIX 工具
- strace
- dtrace
- 配置 Go 開發環境
- go env 命令
- Go 匯編器
- 節點樹
- 進一步了解 Go 構建
- 創建 WebAssembly 代碼
- 對 Webassembly 的簡單介紹
- 為什么 WebAssembly 很重要
- Go 與 WebAssembly
- 示例
- 使用創建好的 WebAssembly 代碼
- Go 編碼風格建議
- 練習和相關鏈接
- 本章小結
- 3 Go基本數據類型
- 03.1 Go循環
- 03.1.1 for循環
- 03.1.2 while循環
- 03.1.3 range關鍵字
- 03.1.4 for循環代碼示例
- 03.3 Go切片
- 03.3.1 切片基本操作
- 03.3.2 切片的擴容
- 03.3.3 字節切片
- 03.3.4 copy()函數
- 03.3.5 多維切片
- 03.3.6 使用切片的代碼示例
- 03.3.7 使用sort.Slice()排序
- 03.4 Go 映射(map)
- 03.4.1 Map值為nil的坑
- 03.4.2 何時該使用Map?
- 03.5 Go 常量
- 03.5.1 常量生成器:iota
- 03.6 Go 指針
- 03.7 時間與日期的處理技巧
- 03.7.1 解析時間
- 03.7.2 解析時間的代碼示例
- 03.7.3 解析日期
- 03.7.4 解析日期的代碼示例
- 03.7.5 格式化時間與日期
- 03.8 延伸閱讀
- 03.9 練習
- 03.10 本章小結
- 9 并發-Goroutines,Channel和Pipeline
- 09.1 關于進程,線程和Go協程
- 09.1.1 Go調度器
- 09.1.2 并發與并行
- 09.2 Goroutines
- 09.2.1 創建一個Goroutine
- 09.2.2 創建多個Goroutine
- 09.3 優雅地結束goroutines
- 09.3.1 當Add()和Done()的數量不匹配時會發生什么?
- 09.4 Channel(通道)
- 09.4.1 通道的寫入
- 09.4.2 從通道接收數據
- 09.4.3 通道作為函數參數傳遞
- 09.5 管道
- 09.6 延展閱讀
- 09.7 練習
- 09.8 本章小結