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

相关推荐
格林威11 分钟前
工业视觉检测:两大主流异常检测开源框架深度对比(PatchCore vs SPADE)
开发语言·人工智能·深度学习·数码相机·计算机视觉·视觉检测·工业相机
苏三说技术16 分钟前
京东二面:假如SQL中join了10张表,如何优化性能?
后端
2zcode16 分钟前
基于Matlab元胞自动机模拟(CA)静态再结晶过程
开发语言·matlab·静态再结晶
dvjr cloi19 分钟前
Spring Framework 中文官方文档
java·后端·spring
研究点啥好呢20 分钟前
滴滴Go后端开发工程师面试题精选:10道高频考题+答案解析
java·开发语言·golang
Levin__NLP_CV_AIGC21 分钟前
py文件中文件复制方法
开发语言·python
yong999025 分钟前
EKF-SLAM在MATLAB上的仿真实现
开发语言·matlab
广州山泉婚姻28 分钟前
C语言三种基本程序结构详解
c语言·开发语言
ictI CABL30 分钟前
SpringBoot3.3.0集成Knife4j4.5.0实战
java
Ruci ALYS31 分钟前
SpringBoot Maven快速上手
spring boot·后端·maven