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

相关推荐
hhb_618几秒前
Python 工程化开发与性能优化实践
开发语言·python·性能优化
前端摸鱼匠几秒前
【AI大模型春招面试题23】大模型的参数量、计算量如何计算?FLOPs与FLOPS的区别?
开发语言·人工智能·面试·求职招聘·batch
江-月*夜1 分钟前
vue3 wordcloud2.js词云使用
开发语言·javascript·vue.js
NiKick1 分钟前
Python 爬虫实战案例 - 获取社交平台事件热度并进行影响分析
开发语言·爬虫·python
程序员晨曦3 分钟前
理解函数调用Function Call
java·运维·服务器
用户69371750013844 分钟前
你每天用的 AI,可能真的被“投毒”了
前端·后端·ai编程
大肥羊学校懒羊羊7 分钟前
质因数个数问题:高效分解算法详解
开发语言·c++·算法
新缸中之脑8 分钟前
用Claude for Word审查法律合同
开发语言·c#·word
沐知全栈开发10 分钟前
SQLite 子查询
开发语言