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

相关推荐
波波0072 小时前
ASP.NET MVC 中的返回类型全集详解
后端·asp.net·mvc
菜鸡儿齐2 小时前
Unsafe方法学习
java·python·学习
汤姆yu2 小时前
IDEA接入Claude Code保姆级教程(Windows专属+衔接前置安装)
java·windows·intellij-idea·openclaw·openclasw安装
prince055 小时前
用户积分系统怎么设计
java·大数据·数据库
96777 小时前
理解IOC控制反转和spring容器,@Autowired的参数的作用
java·sql·spring
SY_FC7 小时前
实现一个父组件引入了子组件,跳转到其他页面,其他页面返回回来重新加载子组件函数
java·前端·javascript
糟糕好吃7 小时前
我让 AI 操作网页之后,开始不想点按钮了
前端·javascript·后端
啵啵鱼爱吃小猫咪7 小时前
机械臂阻抗控制github项目-mujoco仿真
开发语言·人工智能·python·机器人
似水明俊德7 小时前
02-C#
开发语言·c#
耀耀_很无聊7 小时前
09_Jenkins安装JDK环境
java·运维·jenkins