golang中byte和rune的区别?
rune
和byte
在go语言中都是字符类型,从源码来看他们都是别名形式
go
// 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
类型本质上是uint8类型的别名,代表的就是ascll码的一个字符
rune
类型本质上其实是int32类型的别名,代表的就是一个UTF-8字符