Search CTRL + K

Type System in Go

内置类型

基础类型

17 个基础类型(另加 2 个类型别名)是预声明类型(predeclared types)。[1]

byteuint8 的内置别名;runeint32 的内置别名。

复合类型

8 个复合类型。

unsafe pointer 类型

1 个 unsafe pointer 类型,由 golang 标准库 unsafe 包中引入。[2]

类型声明

类型声明(type declaration) 是创建自定义类型的语法糖。

类型定义声明

类型定义(type definition, or type definition declaration) 是创建新类型的方式。

type NewType SourceType

类型别名声明

类型别名声明(type alias declaration) 是创建类型别名的方式。

type NewType = SourceType

  1. https://go101.org/article/type-system-overview.html ↩︎

  2. https://pkg.go.dev/unsafe#Pointer ↩︎