command
Version:
v0.0.0-...-a7405e7
Opens a new window with list of versions in this module.
Published: Mar 28, 2023
License: MIT
Opens a new window with license information.
Imports: 1
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
- byte
byte 是 uint8 的别名,在所有方面都等同于 uint8
按惯例,它用于区分字节值和 8 位无符号整数值。
- rune
rune 是 int32 的别名,在所有方面都等同于 int32
按惯例,它用于区分字符值和整数值。
- string
string 是所有 8 位字节字符串的集合,通常但不一定代表 UTF-8 编码的文本
字符串可能为空,但是不能为 nil
字符串类型的值是不可变的
由上面得解释我们大概可以明白
rune 可以表示得比 byte 多
string 类型的底层是一个 byte 数组
- Go 源码文件默认采用 Unicode 字符集,Unicode 码点和内存中字节序列的变换实现使用了 UTF-8,这使得 Go 编程无需考虑编码转换的问题非常方便
从编码上来分析
- byte 用来强调一个字节代表的数据(例如字符 a 就是 97),而不是数字;
- rune 用来表示 Unicode 的码点,即一个字符
通俗一点
- byte 只能操作简单的字符,不支持中文操作
- rune 能操作任何字符
Documentation
¶
There is no documentation for this package.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.