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

相关推荐
装不满的克莱因瓶16 分钟前
【踩坑】IDEA提交Git .gitignore忽略文件不起作用
java·git·.gitignore·踩坑
都叫我大帅哥16 分钟前
Docker Swarm 部署方案
后端
都叫我大帅哥20 分钟前
在Swarm中部署Nacos并配置外部MySQL
后端
superman超哥21 分钟前
Rust 异步错误处理最佳实践
开发语言·rust·编程语言·rust异步错误处理·rust最佳实践
专注于大数据技术栈23 分钟前
java学习--Collection的迭代器
java·python·学习
脏脏a23 分钟前
C++ STL list 模拟实现:从底层链表到容器封装
开发语言·c++·stl·双链表
熏鱼的小迷弟Liu1 小时前
【消息队列】RabbitMQ的基本架构?
面试·架构·rabbitmq
NAGNIP7 小时前
一文搞懂机器学习中的特征降维!
算法·面试
想摆烂的不会研究的研究生7 小时前
每日八股——Redis(1)
数据库·经验分享·redis·后端·缓存
NAGNIP8 小时前
一文搞懂机器学习中的特征构造!
算法·面试