一个分片只有一个名为list的元素,为什么subslice list [1:]可以工作?

A slice has only one element, named list, why can subslice list[1:] work? For example:

list := []int{1}
fmt.Println(list[1:])
fmt.Println(list[1])

The list hasn't the element with index 1, so the third line causes "panic: runtime error: index out of range", but why does the second line works well?

Well, the language simply defines this to be valid.

Think of the indices used in subslicing as pointing "between" elements:

Slice a Elements:   | 0 | 1 | 2 | 3 | 4 | 5 |
Subslice a[2:]              ^===============
Subslice a[2:4]             ^===========^
Subslice a[6:]                              ^

Your list[1:] slices of the empty slice.