package main
import "fmt"
// 数组清零
func zeroArray(Array *[]int) {
*Array = []int{}
}
func main() {
// 定义
a := []int{1,2,3} // [1 2 3]
b := []int{1:20,4:30} // [0 20 0 0 30]
fmt.Println(a, b)
s1 := "hello"
s := []byte(s1)
fmt.Println(s) //[104 101 108 108 111]
s2 := []int{1,3,4}
zeroArray(&s2)
fmt.Println(s2) // []
}
转载于:https://www.cnblogs.com/huyuan1004/p/11307634.html