Go builtin包提供了go预先声明的函数、变量等的文档。这些函数变量等的实现其实并不是在builtin包里,只是为了方便文档组织。

这些内置的变量、函数、类型无需引入包即可使用。

默认提供的有:

1、常量:

true,false,iota

关于iota,请参考周一的文章“go iota用法”

2、变量

nil

3、函数

func append(slice []Type, elems ...Type) []Type

向slice中添加元素

func cap(v Type) int

返回指定类型的容量,根据不同类型,返回意义不同。

数组: 元素个数 (和len(v)一样).

数组指针: *v的元素个数 (和len(v)一样).

Slice: the maximum length the slice can reach when resliced;如果v==nil, cap(v) 值为0;

Channel: channel 缓存区的容量, 以其中的元素为单位;如果v==nil, cap(v) 值为0;

参考之前的文章“Go内置函数cap”

func close(c chan<- Type)

关闭一个channel

func complex(r, i FloatType) ComplexType

创建一个复数

func copy(dst, src []Type) int

用于slice间复制数据,参考之前的文章“Go内建函数copy”

func delete(m map[Type]Type1, key Type)

删除map中指定key的元素

func imag(c ComplexType) FloatType

返回复数的虚部

func len(v Type) int

返回变量的长度。参考之前的文章“Go内置函数len”

func make(Type, size IntegerType) Type

func new(Type) *Type

func panic(v interface{})

产生一个异常,参考"go异常处理"

func print(args ...Type)

打印输出,可用于调试

func println(args ...Type)

打印输出,可用于调试

func real(c ComplexType) FloatType

返回复数的实部

func recover() interface{}

参考"go异常处理"

4、数据类型

type ComplexType

type FloatType

type IntegerType

type Type

type Type1

type bool

type byte

type complex128

type complex64

type error

type float32

type float64

type int

type int16

type int32

type int64

type int8

type rune

type string

type uint

type uint16

type uint32

type uint64

type uint8

type uintptr

Golang学习 - builtin 包的更多相关文章

  1. Golang学习 - sort 包

    ------------------------------------------------------------ // 满足 Interface 接口的类型可以被本包的函数进行排序. type ...

  2. Golang学习 - reflect 包

    ------------------------------------------------------------ 在 reflect 包中,主要通过两个函数 TypeOf() 和 ValueO ...

  3. Golang学习 - io 包

    ------------------------------------------------------------ 先说一下接口,Go 语言中的接口很简单,在 Go 语言的 io 包中有这样一个 ...

  4. Golang学习 - unsafe 包

    ------------------------------------------------------------ 指针类型: *类型:普通指针,用于传递对象地址,不能进行指针运算. unsaf ...

  5. Golang学习 - errors 包

    ------------------------------------------------------------ Go 语言使用 error 类型来返回函数执行过程中遇到的错误,如果返回的 e ...

  6. Golang学习 - bytes 包

    ------------------------------------------------------------ 对于传入 []byte 的函数,都不会修改传入的参数,返回值要么是参数的副本, ...

  7. Golang学习 - bufio 包

    ------------------------------------------------------------ // bufio 包实现了带缓存的 I/O 操作 -------------- ...

  8. Golang学习 - strings 包

    ------------------------------------------------------------ strings 包与 bytes 包中的函数用法基本一样,不再赘述. 只对 R ...

  9. golang学习笔记--包导入及go 常用命令及参数

    包导入:包导入路劲即代码包在工作区的src目录下的相对路径. 同一个源码文件中导入的多个代码包的最后一个元素不能重复,否则引起编译错误,如果只导入不使用,同样会引起编译错误 若想导入最后一个元素名相同 ...

随机推荐

  1. Java多例模式

    多例模式又划分为有上限多例模式和无上限多例模式两种,没上限的多例模式和直接 new 一个对象没什么差别,此处不做记录. 有上限多例模式:实际上是单例模式的推广,如果它的上限是1,那么就成了单例模式了. ...

  2. C++多线程环境下注意共享资源的释放顺序

    比如我现在写一个多线程下载程序,包含DownloadTask.HttpDownload两个类. class DownloadTask { //省略n行代码 public: int m_threads; ...

  3. mac下安装apc并且使用

    1.到网站下载对应PHP版本apc压缩包http://git.php.net/?p=pecl/caching/apc.git;a=commit;h=08e2ce7ab5f59aea483d877e2b ...

  4. SharePoint 2010 自定义页面出现“项目可能已被其他用户删除或重命名”问题跟踪

    异常详细信息: Microsoft.SharePoint.SPException: 位置 http://portal/Pages/ShowArticle.aspx?id=19&mylist=8 ...

  5. php常见的坑

    10.filesize缓存的问题 PHP的filesize居然会缓存(当然还有不少,这里仅用filesize举例,其它会缓存的函数,以官方文档为准)线上代码经常随机出各种问题,排查了1个月,线上加各种 ...

  6. HE算法与Scaler算法

    HE算法:图像直方图均衡化 Scaler算法:图像缩放 基于matab的scaler实现_图文_百度文库 https://wenku.baidu.com/view/016f5e4002768e9951 ...

  7. JavaScript------字符串与HTML格式相互转换

    转载: http://blog.sina.com.cn/s/blog_4cb0b0fc0100aoo1.html 代码:: 1.将字符转换成Html function encodeHtml(str){ ...

  8. Python 解压缩Zip和Rar文件到指定目录

    #__author__ = 'Joker'# -*- coding:utf-8 -*-import urllibimport osimport os.pathimport zipfilefrom zi ...

  9. 多线程模块:threading

    threading 常见用法: (1) 在 thread 中,我们是通过 thread.start_new_thread(function, args) 来开启一个线程,接收一个函数和该函数的参数,函 ...

  10. osgearth将视点绑定到一个节点上

    _manip->getSettings()->setTetherMode(osgEarth::Util::EarthManipulator:: TETHER_CENTER ); //设置_ ...