Software Tools
Huang Ge Go Language Article: The original value cannot be modified when the function passes to the slice.
The slice data type of Go language is a reference type. When passing a function, sometimes, the original value can be directly modified, sometimes not.Please see the code belowpackage main import "fmt" func changeSlice(x []int, y []int) { x[1] = 100 y = append(y, 20) } func main() { var x, y []int x = []int{2, 3} y = []int{2, 3, 4} changeSlice(x, y) fmt.Println(x, y) } /* [2 100] [2 3 4] slice append */ It is easy to understand how to modify the value through the index, but the append function c