golang/go

x/tour: minor confusion of array and slice length

开放

#79,419 创建于 2026年5月15日

 (2 条评论) (0 个反应) (0 位负责人)Go (19,008 个派生)batch import
DocumentationFixPendinghelp wanted

仓库指标

星标
 (133,883 个星标)
PR 合并指标
 (30 天内没有已合并 PR)

描述

The page about automatic slice ends at https://go.dev/tour/moretypes/10 reads (emphasis mine):

The default is zero for the low bound and the length of the slice for the high bound.

This is a bit confusing because up to that point, slices have always been generated from arrays, not slices. My first thought was "oh, you mean the length of the array for the high bound", which is indeed conformant to the example in the text. But in the code example on the right, slicing from a slice is introduced, so the full meaning is probably something along the lines of "length of the underlying array or slice".

As the result of slicing is also a slice, the term "length of the slice" could further be mistaken (in confusion) to mean the length of the resulting slice (however that might work), that's why I'd suggest adding the word "underlying".

贡献者指南