mirror of
https://github.com/chai2010/advanced-go-programming-book.git
synced 2025-05-24 12:32:21 +00:00
commit
6bf497a0dd
@ -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'}
|
||||
```
|
||||
|
||||
字符串虽然不是切片,但是支持切片操作,不同位置的切片底层也访问的同一块内存数据(因为字符串是只读的,相同的字符串面值常量通常是对应同一个字符串常量):
|
||||
|
Loading…
x
Reference in New Issue
Block a user