一、append是深拷贝,
func main() { a := []int{7, 8, 9} fmt.Printf("%+v\n", a) ap(a) fmt.Println("==", a) app(a) fmt.Println("-a-a", a) } func ap(a []int) { a = append(a, 10) } func app(a []int) { a[0] = 1 }
func main() { a := []int{7, 8, 9} fmt.Printf("%+v\n", a) ap(a) fmt.Println("==", a) app(a) fmt.Println("-a-a", a) } func ap(a []int) { a = append(a, 10) } func app(a []int) { a[0] = 1 }