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

相关推荐
2301_816651227 分钟前
嵌入式C++低功耗设计
开发语言·c++·算法
架构师沉默13 分钟前
Java 终于有自己的 AI Agent 框架了?
java·后端·架构
程序员爱酸奶14 分钟前
ThreadLocal内存泄漏深度解析
java
JCGKS17 分钟前
海量文档单词计数算法方案分析
golang·数据结构与算法·海量数据·搜索引起·倒排查找
用户8511602761221 分钟前
Spring Boot 自动配置原理是什么?
面试
秋水无痕21 分钟前
# 手把手教你从零搭建 AI 对话系统 - React + Spring Boot 实战(一)
前端·后端
czlczl2002092523 分钟前
JVM创建对象过程
java·开发语言
kyriewen24 分钟前
异步编程:从“回调地狱”到“async/await”的救赎之路
前端·javascript·面试
秋水无痕29 分钟前
# 手把手教你从零搭建 AI 对话系统 - React + Spring Boot 实战(二)
前端·后端·面试
qq_4160187232 分钟前
分布式缓存一致性
开发语言·c++·算法