gopl-zh.github.com/ch2/ch2.md

6 lines
831 B
Markdown
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# 第2章 程序结构
Go语言和其他编程语言一样一个大的程序是由很多小的基础构件组成的。变量保存值简单的加法和减法运算被组合成较复杂的表达式。基础类型被聚合为数组或结构体等更复杂的数据结构。然后使用if和for之类的控制语句来组织和控制表达式的执行流程。然后多个语句被组织到一个个函数中以便代码的隔离和复用。函数以源文件和包的方式被组织。
我们已经在前面章节的例子中看到了很多例子。在本章中我们将深入讨论Go程序基础结构方面的一些细节。每个示例程序都是刻意写的简单这样我们可以减少复杂的算法或数据结构等不相关的问题带来的干扰从而可以专注于Go语言本身的学习。