KDOC 317: Goの文字列は長さを保持している
この文書のステータス
- 作成
- 2024-11-29 貴島
- レビュー
- 2024-11-30 貴島
概要
Go言語の文字列(string)は長さを保持したポインタである。イミュータブルに設計されていて伸長しないので、スライスと違って容量は保持していない。
https://github.com/kd-collective/go/blob/493edb29735fd2adf2087b32c60617dad11dc6e1/src/runtime/string.go#L276-L279
type stringStruct struct {
str unsafe.Pointer
len int
}
関連
- 比較: KDOC 310: なぜCの文字列はnull終端なのか?。Cと比較して考えることにした