布尔型

一个布尔类型的值只有两种:true和false

字符

golang中没有专门的字符类型,一般使用byte或rune来保存单个字符

其中byte是int8的别名,rune是int32的别名

// byte is an alias for uint8 and is equivalent to uint8 in all ways. It is
// used, by convention, to distinguish byte values from 8-bit unsigned
// integer values.
type byte = uint8

// rune is an alias for int32 and is equivalent to int32 in all ways. It is
// used, by convention, to distinguish character values from integer values.
type rune = int32

byte一般用来保存ascii码以内的,rune用来保存unicode码,涉及到中文的全部使用rune来表示,因为一个中文字符可能是由多个字节组成的,byte表示不了

func TestChar(t *testing.T) {
var c rune = '中'
fmt.Println(c) // 20013
fmt.Printf("%c\n", c) // 中
}