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

相关推荐
xiangpanf几秒前
PHP爬虫框架:Goutte vs Panther
开发语言·c++·vue.js·php
~无忧花开~3 分钟前
React元素渲染:核心概念全解析
开发语言·前端·javascript·react.js
开开心心就好3 分钟前
免费无广告的礼金记账本,安卓应用
java·前端·ubuntu·edge·pdf·负载均衡·语音识别
像素猎人9 分钟前
pair<类型1, 类型2> 变量名的介绍,自用笔记
开发语言·c++·算法
向往着的青绿色11 分钟前
完全平方数【Letcode279题解】
开发语言·c++·数学·算法·面试·性能优化·动态规划
无籽西瓜a13 分钟前
OSI 七层模型详解及面经
java·网络·后端
marsh020615 分钟前
14 openclaw模板引擎使用:高效渲染动态内容
java·前端·spring·ai·编程·技术
qq_3585896118 分钟前
sylar 配置系统
java·c++·算法
佩奇大王21 分钟前
P103 日期问题
java·开发语言·算法