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

相关推荐
敲敲了个代码4 小时前
从硬编码到 Schema 推断:前端表单开发的工程化转型
前端·javascript·vue.js·学习·面试·职场和发展·前端框架
想回家的一天4 小时前
ECONNREFUSED ::1:8000 前端代理问题
开发语言
cike_y4 小时前
Mybatis之解析配置优化
java·开发语言·tomcat·mybatis·安全开发
WanderInk4 小时前
刷新后点赞全变 0?别急着怪 Redis,这八成是 Long 被 JavaScript 偷偷“改号”了(一次线上复盘)
后端
Jay_Franklin5 小时前
SRIM通过python计算dap
开发语言·python
是一个Bug5 小时前
Java基础50道经典面试题(四)
java·windows·python
Slow菜鸟5 小时前
Java基础架构设计(三)| 通用响应与异常处理(分布式应用通用方案)
java·开发语言
吴佳浩6 小时前
Python入门指南(七) - YOLO检测API进阶实战
人工智能·后端·python
消失的旧时光-19436 小时前
401 自动刷新 Token 的完整架构设计(Dio 实战版)
开发语言·前端·javascript
wadesir6 小时前
Rust中的条件变量详解(使用Condvar的wait方法实现线程同步)
开发语言·算法·rust