golang中byte和rune的区别?

golang中byte和rune的区别?

runebyte在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字符

相关推荐
源代码•宸12 小时前
GoLang写一个火星漫游行动
开发语言·经验分享·后端·golang
i***132412 小时前
【SpringBoot】单元测试实战演示及心得分享
spring boot·后端·单元测试
小尧嵌入式12 小时前
C++中的封装继承多态
开发语言·arm开发·c++
路边草随风13 小时前
flink实现写orc对数据进行分目录(分区表)写入
java·大数据·flink
csbysj202013 小时前
Redis 配置详解
开发语言
s***353013 小时前
SpringMVC新版本踩坑[已解决]
android·前端·后端
行走在电子领域的工匠13 小时前
台达ST:自定义串行通讯传送与接收指令COMRS程序范例四
开发语言·台达plc·st语言编程
geekmice13 小时前
通过账户信息操作加深对DTO,VO,BO理解
java
r***013813 小时前
Java进阶,时间与日期,包装类,正则表达式
java·mysql·正则表达式
t1987512813 小时前
基于因子图与和积算法的MATLAB实现
开发语言·算法·matlab