Files
the-way-to-go_ZH_CN/eBook/06.5.md
AutuanLiu 6d3f1902ba 修复与更正 (#337)
* Update 06.4.md

标点符号错误

* Update 06.5.md

* Update 06.6.md

* Update 06.8.md

修正上一节目录索引错误

* Update 06.8.md

* Update 07.0.md

* Update 07.1.md

* Update 07.6.md

用词不统一

* Update 08.0.md

* Update 08.6.md

用词不统一

* Update 09.0.md

* Update 09.5.md

修改不通顺

* 拼写错误

[建议加上`git remote -v`](https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/)

* Update 10.0.md

* 统一风格

* 调整位置,保证最后一行可以输出

* 保证最后一行可以输出

* 格式

* markdown 修改
2017-03-29 19:03:39 -04:00

22 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 6.5 内置函数
Go 语言拥有一些不需要进行导入操作就可以使用的内置函数。它们有时可以针对不同的类型进行操作例如len、cap 和 append或必须用于系统级的操作例如panic。因此它们需要直接获得编译器的支持。
以下是一个简单的列表,我们会在后面的章节中对它们进行逐个深入的讲解。
|名称|说明|
|---|---|
|close|用于管道通信|
|len、cap|len 用于返回某个类型的长度或数量字符串、数组、切片、map 和管道cap 是容量的意思,用于返回某个类型的最大容量(只能用于切片和 map|
|new、make|new 和 make 均是用于分配内存new 用于值类型和用户定义的类型如自定义结构make 用于内置引用类型切片、map 和管道。它们的用法就像是函数但是将类型作为参数new(type)、make(type)。new(T) 分配类型 T 的零值并返回其地址,也就是指向类型 T 的指针(详见第 10.1 节)。它也可以被用于基本类型:`v := new(int)`。make(T) 返回类型 T 的初始化之后的值,因此它比 new 进行更多的工作(详见第 7.2.3/4 节、第 8.1.1 节和第 14.2.1 节)**new() 是一个函数,不要忘记它的括号**|
|copy、append|用于复制和连接切片|
|panic、recover|两者均用于错误处理机制|
|print、println|底层打印函数(详见第 4.2 节),在部署环境中建议使用 fmt 包|
|complex、real imag|用于创建和操作复数(详见第 4.5.2.2 节)|
## 链接
- [目录](directory.md)
- 上一节:[defer 和追踪](06.4.md)
- 下一节:[递归函数](06.6.md)