In go language, the use of arrays, slices (Slice) and Mapping Tables (map) is often seen. People who have a background in other languages will be more familiar with it, but it is also because of the familiarity that leads to a habit of thinking that often kicks "stone", and I am one of them. Let's say the number of questions:
Nothing else, but in the case of the passing number of the needle to the function, go is like this if you want to pass a number of needles into a function, you have to make sure the size of the numbers
*[] int ) { arr[21}func Main () { arr:new([int.]int ) UpdateItem (arr)}
That's not going to work, and I'll give you a type of mismatch bug that you must write
Func UpdateItem (arr *[]int) { arr[21}
In addition to the needle, you can also use slices to pass the numbers, but this is not the way to go.
Func UpdateItem (arr []int) { arr[21}func Main () { arr: New ([+]int) UpdateItem (arr[:])}
Another doubt is the length of the slice and the definition of capacity, do not know how to make ([]int, 10, 50), how to fill after 40 memory space value? It is possible to access the following 40 spaces through the expansion of the slices. Tile re-expansion must start at 0, as
var slice1 = make ([]int= slice1[0: Len (slice1) +1 ]
This adds a space to the slice.
Third glance in Go