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

相关推荐
tkevinjd几秒前
IO流4(小练习)
java·io流
Vic101011 分钟前
PostgreSQL 中序列(bigserial 和手动序列)的使用与注意事项
java·大数据·数据库·postgresql
Seven971 分钟前
数据结构-堆
java
武子康2 分钟前
大数据-203 scikit-learn 决策树剪枝参数:max_depth/min_samples_leaf 到 min_impurity_decrease
大数据·后端·机器学习
七夜zippoe4 分钟前
异步编程实战:构建高性能Python网络应用
开发语言·python·websocket·asyncio·aiohttp
tianyuanwo5 分钟前
Python虚拟环境深度解析:从virtualenv到virtualenvwrapper
开发语言·python·virtualenv
回家路上绕了弯8 分钟前
Resilience4j全面指南:轻量级熔断限流框架的实战与落地
分布式·后端
SimonKing8 分钟前
你的网站SSL证书又要过期了?这个工具能让你永久告别焦虑
java·后端·程序员
CryptoRzz9 分钟前
印度交易所 BSE 与 NSE 实时数据 API 接入指南
java·c语言·python·区块链·php·maven·symfony
YGGP12 分钟前
【Golang】LeetCode 21. 合并两个有序链表
leetcode·链表·golang