1
0
mirror of https://github.com/chai2010/advanced-go-programming-book.git synced 2025-05-24 12:32:21 +00:00
This commit is contained in:
启程 2018-06-03 14:16:33 +08:00
parent d4081997b5
commit f4777496dc

View File

@ -163,7 +163,7 @@ type StringHeader struct {
分析可以发现“Hello, world”字符串底层数据和以下数组是完全一致的
```go
var data = [...]byte{'h', 'e', 'l', 'l', 'o', ',' ' ', 'w', 'o', 'r', 'l', 'd'}
var data = [...]byte{'h', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd'}
```
字符串虽然不是切片,但是支持切片操作,不同位置的切片底层也访问的同一块内存数据(因为字符串是只读的,相同的字符串面值常量通常是对应同一个字符串常量):