Navigation Menu

Skip to content

Commit

Permalink
all: update
Browse files Browse the repository at this point in the history
  • Loading branch information
changkun committed Jan 23, 2020
1 parent fdd5539 commit b586251
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 63 deletions.
57 changes: 8 additions & 49 deletions README.en-us.md
@@ -1,55 +1,14 @@
<div align="center">
<img src="book/assets/header.png" alt="logo" />
<br/><br/>
<a href="./README.en-us.md"><img src="https://img.shields.io/badge/lang-English-blue.svg?longCache=true&style=flat-square" alt="en-us"/></a>
<a href="./README.md"><img src="https://img.shields.io/badge/lang-简体中文-red.svg?longCache=true&style=flat-square" alt="zh-cn"/></a>
<a href="./LICENSE"><img src="https://img.shields.io/github/license/changkun/go-under-the-hood.svg?style=flat-square"/></a>
<a href="./LICENSE"><img src="https://img.shields.io/badge/license-CC%20BY--NC--ND%204.0-lightgrey.svg?style=flat-square"/></a>
<a href="https://www.paypal.me/changkunde/4.99eur"><img src="https://img.shields.io/badge/donate-PayPal-104098.svg?style=popout-square&logo=PayPal"/></a>
<a href="https://t.me/joinchat/FEeulA4zgj2DsBbudBqMcQ"><img src="https://img.shields.io/badge/chat-telegram-%232CA5E0.svg?logo=telegram&logoColor=white&style=flat-square"/></a>
<br/><br/>
<p>A source code study of Go | Based on <code>go1.14</code></p>
</div>

## To Readers

The Go language has been released for ten years since its inception in 2009.
During the past decade, the popularity of Go has gradually increased. The Go team releases a new version of Go every six months.
Looking at the history of most programming languages, it’s amazing that Go itself doesn't change too much during its evolution. The Go users are able to write backward-compatible applications continuesly.

From the perspective of language design, Go is designed to be simplicity, low cost of parallelism and concurrency.
It's hard not to be curious regarding the implementation mechanisms behind Go and the specific working principles behind its elegant design.
This book is a book all about Go language source code.

Readers of this book may be curious: language design is always evolving, source code is always changing, why bother to study the source code that may never be applied in actual work?
There is a saying that "software engineering happens when the code is read by a non-original author". During the process of reading the source code, we gain further and deeper understanding to the language itself.
More importantly, we can understand the fundamentals behind a design, and what are the technical engineering practices while implementing such a design.

In addition, there will be readers asking, there are so many articles on source code analysis, why should you wrote yet another book on source code analysis?
A very important reason is that when I started to read the Go source and other related articles,
it is found that most of the existing articles has been outdated, and there is no process in analyzing how the code was evolved, i.e. the background, related knowledge, and development history of a piece of code.
In the meantime, the development of the Go runtime is quite active, so I hope to be able to learn more about the latest version of the development while reading the code, as well as be able to have a certain understanding of the evolutionary history.

## Structure and Contents

This book covers the core source code of the entire Go language, including but not limited to the Go runtime `runtime` that Go users can directly reach, the compiler `cmd/compile` related to key language features, and many important standard libraries `sync`/`reflect`/`errors` and so on.
In rare cases, this book will cover the implementation differences cross different platforms, primarily based on Linux/Darwin amd64 and WebAssembly introduced in Go 1.11.

The book is divided into four parts. The first part briefly reviews the basic theories related to the Go runtime and the compiler, and briefly discusses the life cycle of the Go program in its final chapter.
The second part focuses on Go's runtime mechanism, which includes the scheduler, memory allocator, garbage collector, debugging mechanism, and ABI for the Go program.
The third part covers Go compiler mechanism, including the Go compiler translation for keywords, the behavior for cgo programs, and the linker.
The last part of the book discusses some standard libraries that rely on the runtime and compiler, as well as the package that are important to our daily development. Note that rhis book only introduces the cooperation between these standard libraries and the runtime and compiler, and does not analyze the source code of the entire package.

## Getting started

- [🇨🇳 简体中文](./book/zh-cn/TOC.md)
- 🇬🇧 English (Unplanned)
<img src="book/assets/cover.png" alt="logo" height="550" align="right" />

## Acknowledgements
# Go: Under The Hood

The author has limited time and language skills. If readers find any mistakes of the book or any language improvements, please feel free to open an [Issues](https://github.com/changkun/go-under-the-hood/issues/new/choose) or start a [Pull request](https://github.com/changkun/go-under-the-hood/pulls). For detailed guidelines, please refer to [How to contribute](./CONTRIBUTING.md).
![](https://img.shields.io/badge/lang-简体中文-red.svg?longCache=true&style=flat-square)
![](https://img.shields.io/github/license/changkun/go-under-the-hood.svg?style=flat-square)
![](https://img.shields.io/badge/license-CC%20BY--NC--ND%204.0-lightgrey.svg?style=flat-square)
[![](https://img.shields.io/badge/donate-PayPal-104098.svg?style=popout-square&logo=PayPal)](https://www.paypal.me/changkunde/4.99eur)
[![](https://img.shields.io/badge/chat-telegram-%232CA5E0.svg?logo=telegram&logoColor=white&style=flat-square)](https://t.me/joinchat/FEeulA4zgj2DsBbudBqMcQ)

The author would like to thank [@egonelbre](https://github.com/egonelbre/gophers) for his charming gopher design.
🇬🇧 English version of the book is not provided yet, the author apologies for any inconveniences.

<div align="center">
<p></p>
Expand Down
20 changes: 13 additions & 7 deletions README.md
Expand Up @@ -34,7 +34,8 @@ Go 语言从 2009 年诞生之初已有十余年的历史。
这使得笔者在阅读这类资料时无法鉴别其内容的正确性。由于 Go 运行时的开发是相当活跃的,
因此本书希望对整个 Go 源码的技术原理和演进历史进行一个相对完整的介绍。

注意,目前所有正文内容均为临时写作阶段,内容可能较为混乱,当全文初稿完成后会针对以下目标进行优化:
**注意,目前所有正文内容均为临时写作阶段,内容可能较为混乱,部分内容为空属于正常现象。**
当全文初稿完成后会针对以下目标进行优化:

- 行文逻辑优化,补充大量配图
- 源码删减,只保留核心逻辑
Expand All @@ -52,10 +53,15 @@ Go 语言从 2009 年诞生之初已有十余年的历史。

![](./book/assets/book.png)

- 第一部分简要回顾了与 Go 运行时及编译器相关的基础理论,并在其最后一章中简要讨论了 Go 程序的生命周期。
- 第二部分着重关注 Go 的运行时机制,这包括调度器、内存分配器、垃圾回收器、调试机制以及程序的 ABI 以及运行时的类型系统等。
- 第三部分则着眼于 Go 的编译器、链接器以及相关工具链,包括 Go 编译器对关键字的翻译行为、逃逸分析、对 cgo 程序的翻译过程等等。
- 第四部分则讨论了一些依赖运行时和编译器的标准库,本书只介绍这些标准库与运行时和编译器之间的配合,并不会完整的整个包的源码进行分析。
- 第一部分简要回顾了与 Go 运行时及编译器相关的基础理论,包括程序基础、并行编程、调度算法以及内存管理等主题,并在其最后一章中简要讨论了 Go 程序的生命周期。
- 第二部分着重关注 Go 的运行时机制,这包括 Go 运行时实现的调度器、内存分配器、垃圾回收器、核心语言特性以及程序的 ABI 以及运行时的类型系统等。
- 第三部分则着眼于 Go 相关的工具链,包括编译器、链接器、依赖管理以及运行时调试等工具,其中包括 Go 编译器对代码进行逃逸分析等语义分析、对 cgo 程序的翻译和链接过程、Go 程序的自举等等。
- 第四部分则讨论了一些依赖运行时和编译器的标准库,如 `sync``net` 等;除此之外,还讨论了一些与核心语言特性相关的标准库,如 `context``errors` 以及 `contracts`

本书的参考文献分为两种不同的类型。在每个小节后都附有进一步阅读的参考文献,
这类文献的主要目的是将读者指向书中尚未进一步深入探讨的话题,通常这类话题已经超出全书的讨论范畴,
这类文献给对该内容感兴趣的读者一个进一步阅读的空间;
其二是书后的参考文献,这些文献是在编写本书时引用、参考的主要文献,读者可以根据自己的需求选择并查阅本书参考过的文献。

## 阅读的预备知识

Expand All @@ -77,9 +83,9 @@ Go 语言从 2009 年诞生之初已有十余年的历史。

## 致谢

本书的写作离不开诸多热心读者的支持,笔者收到了来自下列人员的有帮助的评价和勘误:@two, @yangxikun, @cnbailian, @choleraehyq, @PureWhiteWu。笔者真心感谢这些人对本书内容的质疑与指正。当然,书中还可能有错误存在,希望得到更多的指正和反馈。
本书的写作离不开诸多热心读者的支持,笔者收到了来自下列人员的有帮助的评价和勘误:`@two`, `@yangxikun`, `@cnbailian`, `@choleraehyq`, `@PureWhiteWu`。笔者真心感谢这些人对本书内容的质疑与指正。当然,书中还可能有错误存在,希望得到更多的指正和反馈。

另外,笔者还希望感谢他在 [Go 夜读](https://reading.developerlearning.cn/) 社区小组的朋友们表示感谢,感谢他们提供让笔者持续接触 Go 的机会,他们是:@yangwenmai, @qcrao, @eddycjy, @FelixSeptem
笔者还希望感谢他所在 [Go 夜读](https://reading.developerlearning.cn/) 社区小组的成员以及社区里的朋友们,感谢他们努力建设的 Go 语言社区环境,以及积极参与并讨论 Go 语言的相关问题,他们是:`@yangwenmai`, `@qcrao`, `@eddycjy`, `@FelixSeptem``@cch123`

最后,作者特别希望感谢 [@egonelbre](https://github.com/egonelbre/gophers) 所提供的 gopher 图片设计。

Expand Down
21 changes: 14 additions & 7 deletions book/zh-cn/preface.md
Expand Up @@ -31,7 +31,9 @@ Go 语言从 2009 年诞生之初已有十余年的历史。
这使得笔者在阅读这类资料时无法鉴别其内容的正确性。由于 Go 运行时的开发是相当活跃的,
因此本书希望对整个 Go 源码的技术原理和演进历史进行一个相对完整的介绍。

注意,目前所有正文内容均为临时写作阶段,内容可能较为混乱,当全文初稿完成后会针对以下目标进行优化:

**注意,目前所有正文内容均为临时写作阶段,内容可能较为混乱,部分内容为空属于正常现象。**
当全文初稿完成后会针对以下目标进行优化:

- 行文逻辑优化,补充大量配图
- 源码删减,只保留核心逻辑
Expand All @@ -49,10 +51,15 @@ Go 语言从 2009 年诞生之初已有十余年的历史。

![](./book/assets/book.png)

- 第一部分简要回顾了与 Go 运行时及编译器相关的基础理论,并在其最后一章中简要讨论了 Go 程序的生命周期。
- 第二部分着重关注 Go 的运行时机制,这包括调度器、内存分配器、垃圾回收器、调试机制以及程序的 ABI 以及运行时的类型系统等。
- 第三部分则着眼于 Go 的编译器、链接器以及相关工具链,包括 Go 编译器对关键字的翻译行为、逃逸分析、对 cgo 程序的翻译过程等等。
- 第四部分则讨论了一些依赖运行时和编译器的标准库,本书只介绍这些标准库与运行时和编译器之间的配合,并不会完整的整个包的源码进行分析。
- 第一部分简要回顾了与 Go 运行时及编译器相关的基础理论,包括程序基础、并行编程、调度算法以及内存管理等主题,并在其最后一章中简要讨论了 Go 程序的生命周期。
- 第二部分着重关注 Go 的运行时机制,这包括 Go 运行时实现的调度器、内存分配器、垃圾回收器、核心语言特性以及程序的 ABI 以及运行时的类型系统等。
- 第三部分则着眼于 Go 相关的工具链,包括编译器、链接器、依赖管理以及运行时调试等工具,其中包括 Go 编译器对代码进行逃逸分析等语义分析、对 cgo 程序的翻译和链接过程、Go 程序的自举等等。
- 第四部分则讨论了一些依赖运行时和编译器的标准库,如 `sync``net` 等;除此之外,还讨论了一些与核心语言特性相关的标准库,如 `context``errors` 以及 `contracts`

本书的参考文献分为两种不同的类型。在每个小节后都附有进一步阅读的参考文献,
这类文献的主要目的是将读者指向书中尚未进一步深入探讨的话题,通常这类话题已经超出全书的讨论范畴,
这类文献给对该内容感兴趣的读者一个进一步阅读的空间;
其二是书后的参考文献,这些文献是在编写本书时引用、参考的主要文献,读者可以根据自己的需求选择并查阅本书参考过的文献。

## 阅读的预备知识

Expand All @@ -70,9 +77,9 @@ Go 语言从 2009 年诞生之初已有十余年的历史。

## 致谢

本书的写作离不开诸多热心读者的支持,笔者收到了来自下列人员的有帮助的评价和勘误:@two, @yangxikun, @cnbailian, @choleraehyq, @PureWhiteWu。笔者真心感谢这些人对本书内容的质疑与指正。当然,书中还可能有错误存在,希望得到更多的指正和反馈。
本书的写作离不开诸多热心读者的支持,笔者收到了来自下列人员的有帮助的评价和勘误:`@two`, `@yangxikun`, `@cnbailian`, `@choleraehyq`, `@PureWhiteWu`。笔者真心感谢这些人对本书内容的质疑与指正。当然,书中还可能有错误存在,希望得到更多的指正和反馈。

另外,笔者还希望感谢他在 [Go 夜读](https://reading.developerlearning.cn/) 社区小组的朋友们表示感谢,感谢他们提供让笔者持续接触 Go 的机会,他们是:@yangwenmai, @qcrao, @eddycjy, @FelixSeptem
笔者还希望感谢他所在 [Go 夜读](https://reading.developerlearning.cn/) 社区小组的成员以及社区里的朋友们,感谢他们努力建设的 Go 语言社区环境,以及积极参与并讨论 Go 语言的相关问题,他们是:`@yangwenmai`, `@qcrao`, `@eddycjy`, `@FelixSeptem``@cch123`

最后,作者特别希望感谢 [@egonelbre](https://github.com/egonelbre/gophers) 所提供的 gopher 图片设计。

Expand Down

0 comments on commit b586251

Please sign in to comment.