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

相关推荐
l1t1 分钟前
在python 3.14 容器中安装和使用chdb包
开发语言·python·clickhouse·chdb
梵刹古音2 分钟前
【C++】函数重写
开发语言·c++
Vic1010114 分钟前
算法D1-20260212:双指针专题
java·数据结构·算法
大魔王71936 分钟前
进程线程和协程一
后端
民国二十三画生43 分钟前
C++(兼容 C 语言) 的标准输入语法,用来读取一行文本
c语言·开发语言·c++
icebreaker1 小时前
Mokup:构建工具友好的可视化 Mock 工具
前端·javascript·后端
Codiggerworld1 小时前
从字节码到JVM:深入理解Java的“一次编写,到处运行”魔法
java·开发语言·jvm
_codemonster1 小时前
配置Tomcat时为啥要配置Artifacts
java·tomcat·firefox
无心水1 小时前
2025,一路有你!
java·人工智能·分布式·后端·深度学习·架构·2025博客之星