go.dev favicon

Arrays, slices (and strings): The mechanics of 'append' - The Go Programming Language

6
公开标注数
6
参与人数
2026-07-26 10:01:15
首次 Whisper

本页的公开 Whisper

划选高亮2026-07-26 16:25:15
原文高亮摘录
Even though the slice header is passed by value
Whisper 随想笔记
This is exactly why slices feel like references even though they're not.
划选高亮2026-07-26 13:22:15
原文高亮摘录
s important to understand that even though a slice contains a pointer
Whisper 随想笔记
So it's like a struct with a pointer inside? That actually clears things up.
划选高亮2026-07-26 13:13:15
原文高亮摘录
s important to understand that even though a slice contains a pointer
Whisper 随想笔记
Yeah, took me a while to get that slices are values, not just pointers.
划选高亮2026-07-26 10:19:15
原文高亮摘录
A slice is not an array.
Whisper 随想笔记
Yeah, but honestly the distinction only bites you when you mess with append too much.
划选高亮2026-07-26 10:10:15
原文高亮摘录
A slice is not an array.
Whisper 随想笔记
Always forget this—then I wonder why changing a slice changes the original array.
划选高亮2026-07-26 10:01:15
原文高亮摘录
A slice is not an array.
Whisper 随想笔记
Wait, so a slice is like a view into an array, not the array itself? Mind blown.

分享本页 Whisper

分享到 X
短链接
https://domwhisper.com/s/5dc012b6bd55
嵌入代码
<iframe src="https://domwhisper.com/embed/5dc012b6bd55" width="100%" height="480" style="border:0;border-radius:16px" loading="lazy"></iframe>

看看大家在 go.dev 上讨论了什么

安装 DomWhisper,浏览网页时实时查看 whisper,也可以加入讨论。

获取插件