跳至主要内容

array 型別 & slice 型別

刪除最後一個元素

slice1 = slice1[:len(slice1)-1]
slice2 = append(slice2[:len(slice2)-1])

用 make 宣告切片

// 宣告變數 mySlice 並將容量為 0 的切片賦值予之
var mySlice []int = make([]int, 0)
提示

func make(t Type, size ...IntegerType) Type

https://pkg.go.dev/builtin#make