func main(){ var array [10]int sliceA := array[0:5] append(sliceA, 4) fmt.Println(sliceA) }
Error : append(sliceA, 4
you may try this:
sliceA = append(sliceA, 4)
built-in function append([]type, ...type) returns an array/slice of type, which should be assigned to the value you wanted, while the input array/slice is just a source. Simply, outputSlice = append(sourceSlice, appendedValue)
append([]type, ...type)
outputSlice = append(sourceSlice, appendedValue)