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

相关推荐
better_liang3 分钟前
每日Java面试场景题知识点之-MCP协议在Java开发中的应用实践
java·spring boot·ai·mcp·企业级开发
河阿里3 分钟前
SpringBoot :使用 @Configuration 集中管理 Bean
java·spring boot·spring
xiaoshuaishuai83 分钟前
C# Codex 脚本编写
java·服务器·数据库·c#
Flittly5 分钟前
【SpringSecurity新手村系列】(4)验证码功能实现
java·spring boot·安全·spring
Flittly10 分钟前
【SpringSecurity新手村系列】(3)自定义登录页与表单认证
java·笔记·安全·spring·springboot
xiaoye-duck14 分钟前
【C++:C++11】C++11新特性深度解析:从类新功能、Lambda表达式到包装器实战
开发语言·c++·c++11
qq_120840937114 分钟前
Three.js 大场景分块加载实战:从全量渲染到可视集调度
开发语言·javascript·数码相机
csbysj202020 分钟前
Pandas 常用函数
开发语言
无心水25 分钟前
OpenClaw技术文档/代码评审/测试用例生成深度实战
网络·后端·架构·测试用例·openclaw·养龙虾
小小码农Come on38 分钟前
C++访问QML控件-----QML访问C++对象属性和方法
java·开发语言·c++