创建:

    1. arr1 := new([len]type)
    2. slice1 := make([]type, len)

    初始化:

    1. arr1 := [...]type{i1, i2, i3, i4, i5}
    2. arrKeyValue := [len]type{i1: val1, i2: val2}
    3. var slice1 []type = arr1[start:end]

    (1)如何截断数组或者切片的最后一个元素:

    1. line = line[:len(line)-1]

    (2)如何使用 for 或者 for-range 遍历一个数组(或者切片):

    1. for i:=0; i < len(arr); i++ {
    2. = arr[i]
    3. }
    4. for ix, value := range arr {
    5. }

    (3)如何在一个二维数组或者切片 arr2Dim 中查找一个指定值 V

    1. found := false
    2. Found: for row := range arr2Dim {
    3. for column := range arr2Dim[row] {
    4. if arr2Dim[row][column] == V{
    5. found = true
    6. break Found
    7. }
    8. }
    9. }