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

相关推荐
kyle~2 分钟前
Python---Flask 轻量级Web框架
开发语言·python·flask
云深处@24 分钟前
【C++11】特殊类&&单例模式
开发语言·c++
烟花落o30 分钟前
算法的时间复杂度和空间复杂度
开发语言·数据结构·笔记·算法
玹外之音35 分钟前
Spring AI 实战:手把手教你构建支持多会话管理的智能聊天服务
java·spring
西门吹-禅38 分钟前
node js 性能处理
开发语言·javascript·ecmascript
我不是8神40 分钟前
go-zero微服务框架总结
开发语言·微服务·golang
Ronaldinho Gaúch1 小时前
算法题中的日期问题
开发语言·c++·算法
callJJ1 小时前
Spring Bean 生命周期详解——从出生到销毁,结合源码全程追踪
java·后端·spring·bean·八股文
怒放吧德德1 小时前
AsyncTool + SpringBoot:轻量级异步编排最佳实践
java·后端
麦德泽特1 小时前
机器人赛事系统架构:基于UDT和MQTT的低延迟、高可靠通信
c语言·开发语言·安全·系统架构·机器人