go-under-the-hood

module
Version: v0.0.0-...-e6da185 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2021 License: MIT

README

logo

Go 语言原本

当前内容基于 go1.15

Go 语言从 2009 年诞生之初已有十余年的历史。 纵观大多数编程语言的历史进程,令人惊讶的是 Go 语言自身在进化的这十余年间, 语言本身并未发生太大变化,Go 语言的用户能够持续不断写出向后兼容的应用。 从语言设计的角度而言,作为一门从诞生之初就考虑低成本、高并发、简洁等原则的语言, 很难让人不对其简洁设计背后的各项实现机制以及具体工作原理所好奇。 本书就是一本讨论 Go 语言源码工程中的技术原理及其演进历程的书籍。

致读者的话

读者可能会好奇,设计总在演进、源码总在变化,为什么要耗费力气研究实际工作中可能永远不会接触的源码? 笔者以为不然,因为『软件工程发生在代码被非原作者阅读之时』,在阅读源码的过程中, 我们除了能进一步加深对语言本身的理解,更重要的则是理解某个设计背后所使用的根本原理, 以及当其他人在实现这个设计的过程中发生的工程决策、实践与实现技巧。 代码总是可以推倒重来,但原理却能『永生』。

本书的创作愿景是涵盖整个 Go 语言的方方面面。这包括用户代码能直接接触的 Go 运行时组件、 与关键语言特性强相关的工具链、诸多重要的标准库等等。在部分情况下, 本书会讨论不同平台下的实现差异,但着重以 Linux/amd64 为主。

阅读的预备知识

阅读本书的读者应该具备一些基本的计算机科学素养,至少学过一门程序设计课程以及数据结构的课程,例如能够熟悉地谈论散列表、红黑树等概念。若你具备基本的离散数学概率论知识,对谓词、随机变量等数学概念具有一定程度的理解,那么将会对阅读本书的部分章节有所帮助。

本书并未要求读者已经掌握使用 Go 语言,因此会在开篇快速介绍 Go 的语言规范。但如果你已经具备 Go 语言编码和相关开发经验,则会对阅读本书有所帮助。

免责声明

注意,目前本书还属于相当早期的创作阶段。如果读者在阅读过程中怀疑某段内容的描述是错误的, 那么它很可能就是错误的。本书目前的大致创作进度:█░░░░░░░░░ (9.9%/100%)

开始阅读

社区的支持

本书的主页( https://golang.design/under-the-hood )以及 GitHub 仓库( https://github.com/golang-design/under-the-hood )上可以找到本书的更新情况以及一些额外的参考资料。 这是一本属于 golang.design initiative 旗下创作的开源书籍,读者还可以在 GitHub 仓库上发起关于本书内容的问题,或报告本书存在的错误,甚至参与创作。 笔者欢迎您在 GitHub 仓库上提交 IssuesPull Request。 其具体细节请参考如何参与贡献。 如果您想要关注本仓库的更新情况,可以点击仓库的 Watch。如果您喜欢本书,我们也非常高兴能够收到您的 Star 和资助。

致谢

本书的主笔(@changkun)首先希望感谢 Go 夜读 的创始人 @yangwenmaigolang.design 计划提供赞助。 其次,我们还希望感谢 Go 夜读 社区小组的核心成员,感谢他们努力建设的 Go 语言社区环境,他们是:@qcrao, @eddycjy, @FelixSeptem,以及社区里的朋友们积极参与并讨论 Go 语言的相关问题,他们是:@cch123

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

最后,特别感谢 @egonelbre 所提供的 Gopher 图片设计。

许可

© 2018-2020 The golang.design Initiative Authors. Licensed under CC-BY-NC-ND 4.0.

Directories

Path Synopsis
demo
gosrc
cmd/cgo
Cgo enables the creation of Go packages that call C code.
Cgo enables the creation of Go packages that call C code.
cmd/compile
Compile, typically invoked as “go tool compile,” compiles a single Go package comprising the files named on the command line.
Compile, typically invoked as “go tool compile,” compiles a single Go package comprising the files named on the command line.
cmd/go
Go is a tool for managing Go source code.
Go is a tool for managing Go source code.
context
Package context defines the Context type, which carries deadlines, cancellation signals, and other request-scoped values across API boundaries and between processes.
Package context defines the Context type, which carries deadlines, cancellation signals, and other request-scoped values across API boundaries and between processes.
errors
Package errors implements functions to manipulate errors.
Package errors implements functions to manipulate errors.
fmt
os/signal
Package signal implements access to incoming signals.
Package signal implements access to incoming signals.
plugin
Package plugin implements loading and symbol resolution of Go plugins.
Package plugin implements loading and symbol resolution of Go plugins.
reflect
Package reflect implements run-time reflection, allowing a program to manipulate objects with arbitrary types.
Package reflect implements run-time reflection, allowing a program to manipulate objects with arbitrary types.
runtime
Package runtime contains operations that interact with Go's runtime system, such as functions to control goroutines.
Package runtime contains operations that interact with Go's runtime system, such as functions to control goroutines.
runtime/cgo
Package cgo contains runtime support for code generated by the cgo tool.
Package cgo contains runtime support for code generated by the cgo tool.
runtime/debug
Package debug contains facilities for programs to debug themselves while they are running.
Package debug contains facilities for programs to debug themselves while they are running.
runtime/metrics
Package metrics provides a stable interface to access implementation-defined metrics exported by the Go runtime.
Package metrics provides a stable interface to access implementation-defined metrics exported by the Go runtime.
runtime/race
Package race implements data race detection logic.
Package race implements data race detection logic.
sync
Package sync provides basic synchronization primitives such as mutual exclusion locks.
Package sync provides basic synchronization primitives such as mutual exclusion locks.
sync/atomic
Package atomic provides low-level atomic memory primitives useful for implementing synchronization algorithms.
Package atomic provides low-level atomic memory primitives useful for implementing synchronization algorithms.
syscall
Package syscall contains an interface to the low-level operating system primitives.
Package syscall contains an interface to the low-level operating system primitives.
syscall/js
Package js gives access to the WebAssembly host environment when using the js/wasm architecture.
Package js gives access to the WebAssembly host environment when using the js/wasm architecture.
testing
Package testing provides support for automated testing of Go packages.
Package testing provides support for automated testing of Go packages.
time
Package time provides functionality for measuring and displaying time.
Package time provides functionality for measuring and displaying time.
unsafe
Package unsafe contains operations that step around the type safety of Go programs.
Package unsafe contains operations that step around the type safety of Go programs.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL