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

相关推荐
yue00816 分钟前
C# 更改窗体样式
开发语言·c#
普通网友20 分钟前
C++中的适配器模式
开发语言·c++·算法
风闲121722 分钟前
Qt源码编译记录
开发语言·qt
Felix_XXXXL37 分钟前
mysql查看binlog日志
java·后端
leonardee41 分钟前
Plugin ‘mysql_native_password‘ is not loaded`
java·后端
普通网友43 分钟前
C++中的委托构造函数
开发语言·c++·算法
珹洺1 小时前
Java-Spring入门指南(三十一)Android意图(Intent)
android·java·spring
Seven971 小时前
剑指offer-39、平衡⼆叉树
java
月上柳青1 小时前
OpenWrt系统上配置batman-adv快速开始与配置详解
开发语言·mysql·php
全栈陈序员1 小时前
基于Rust 实现的豆瓣电影 Top250 爬虫项目
开发语言·爬虫·rust