内容简介:内置类型值类型:引用类型:(指针类型)
内置类型
值类型:
bool int(32 or 64), int8, int16, int32, int64 uint(32 or 64), uint8(byte), uint16, uint32, uint64 float32, float64 string complex64, complex128 array -- 固定长度的数组
引用类型:(指针类型)
slice -- 序列数组(最常用) map -- 映射 chan -- 管道
内置函数
Go 语言拥有一些不需要进行导入操作就可以使用的内置函数。它们有时可以针对不同的类型进行操作,例如:len、cap 和 append,或必须用于系统级的操作,例如:panic。因此,它们需要直接获得编译器的支持。
append -- 用来追加元素到数组、slice中,返回修改后的数组、slice close -- 主要用来关闭channel delete -- 从map中删除key对应的value panic -- 停止常规的goroutine (panic和recover:用来做错误处理) recover -- 允许程序定义goroutine的panic动作 imag -- 返回complex的实部 (complex、real imag:用于创建和操作复数) real -- 返回complex的虚部 make -- 用来分配内存,返回Type本身(只能应用于slice, map, channel) new -- 用来分配内存,主要用来分配值类型,比如int、struct。返回指向Type的指针 cap -- capacity是容量的意思,用于返回某个类型的最大容量(只能用于切片和 map) copy -- 用于复制和连接slice,返回复制的数目 len -- 来求长度,比如string、array、slice、map、channel ,返回长度 print、println -- 底层打印函数,在部署环境中建议使用 fmt 包
内置接口error
type error interface {
//只要实现了Error()函数,返回值为String的都实现了err接口
Error() String
}
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
The Zen of CSS Design
Dave Shea、Molly E. Holzschlag / Peachpit Press / 2005-2-27 / USD 44.99
Proving once and for all that standards-compliant design does not equal dull design, this inspiring tome uses examples from the landmark CSS Zen Garden site as the foundation for discussions on how to......一起来看看 《The Zen of CSS Design》 这本书的介绍吧!