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

8 lines
1.2 KiB
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.

# 第10章 包和工具
现在随便一个小程序的实现都可能包含超过10000个函数。然而作者一般只需要考虑其中很小的一部分和做很少的设计因为绝大部分代码都是由他人编写的它们通过类似包或模块的方式被重用。
Go语言有超过100个的标准包译注可以用`go list std | wc -l`命令查看标准包的具体数目标准库为大多数的程序提供了必要的基础构件。在Go的社区有很多成熟的包被设计、共享、重用和改进目前互联网上已经发布了非常多的Go语言开源包它们可以通过 http://godoc.org 检索。在本章,我们将演示如何使用已有的包和创建新的包。
Go还自带了工具箱里面有很多用来简化工作区和包管理的小工具。在本书开始的时候我们已经见识过如何使用工具箱自带的工具来下载、构建和运行我们的演示程序了。在本章我们将看看这些工具的基本设计理论和尝试更多的功能例如打印工作区中包的文档和查询相关的元数据等。在下一章我们将探讨testing包的单元测试用法。