The Go Programming Language

The size of an array is part of its type, so [3]int and [4]int are different types.

添加于 2022年6月6日星期一 上午8:59:36

您在位置 #2140-2141的标注

The size of an array is part of its type, so [3]int and [4]int are different types. The size must be a constant expression, that is, an expression whose value can be computed as the program is being compiled.

添加于 2022年6月6日星期一 上午8:59:58

您在位置 #2140-2142的标注

%x to print all the elements of an array or slice of bytes in hexadecimal, %t to show a boolean, and %T to display the type of a value.

添加于 2022年6月6日星期一 上午9:06:55

您在位置 #2167-2168的标注

Unlike arrays, slices are not comparable, so we cannot use == to test whether two slices contain the same elements. The standard library provides the highly optimized bytes.Equal function for comparing two slices of bytes ([]byte), but for other types of slice, we must do the comparison ourselves:

添加于 2022年6月6日星期一 上午11:15:26

您在位置 #2234-2236的标注

Under the hood, make creates an unnamed array variable and returns a slice of it; the array is accessible only through the returned slice. In the first form, the slice is a view of the entire array. In the second, the slice is a view of only the array’s first len elements, but its capacity includes the entire array. The additional elements are set aside for future growth.

添加于 2022年6月6日星期一 上午11:20:38

您在位置 #2263-2266的标注

For efficiency, the new array is usually somewhat larger than the minimum needed to hold x and y. Expanding the array by doubling its size at each expansion avoids an excessive number of allocations and ensures that appending a single element takes constant time on average. This program demonstrates the effect:

添加于 2022年6月6日星期一 上午11:25:51

您在位置 #2293-2296的标注

When you have a value of an interface type, you know nothing about what it is; you know only what it can do, or more precisely, what behaviors are provided by its methods.

添加于 2022年6月8日星期三 上午9:32:07

您在位置 #3966-3967的标注

Because the empty interface type places no demands on the types that satisfy it, we can assign any value to the empty interface.

添加于 2022年6月8日星期三 上午9:49:35

您在位置 #4091-4092的标注