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

相关推荐
liulilittle几秒前
OPENPPP2 CTCP 协议栈 + 内置 TC Hairpin NAT 内核态程序
c语言·开发语言·网络·c++·信息与通信·通信
稻草猫.2 分钟前
Spring AOP
java·后端·spring·java-ee·idea
Moment3 分钟前
面试爱问底层时,我是怎么读大型前端源码的❓❓❓
前端·javascript·面试
阿聪谈架构5 分钟前
第06章:AI RAG 检索增强生成 — 从零到生产(下)
人工智能·后端
第二只羽毛6 分钟前
C++ 高并发内存池4
java·大数据·linux·c++·算法
有一个好名字8 分钟前
常用注册中心大全(主流 5 个)介绍
java
NCIN EXPE11 分钟前
SpringBoot教程(三十二) SpringBoot集成Skywalking链路跟踪
spring boot·后端·skywalking
yhyyht11 分钟前
JVM调优学习笔记(一)
后端
lagrahhn13 分钟前
python面向对象中__new__和__init__区别
后端·python·程序员
羚羊角uou15 分钟前
【Linux网络】select详解
linux·服务器·开发语言·网络·c++