运行 ❯
获得您
自己的
网站
×
更改方向
更改主题,暗/亮
去 Spaces
package main import ("fmt") func main() { myslice1 := make([]int, 5, 10) fmt.Printf("myslice1 = %v\n", myslice1) fmt.Printf("length = %d\n", len(myslice1)) fmt.Printf("capacity = %d\n", cap(myslice1)) myslice2 := make([]int, 5) fmt.Printf("myslice2 = %v\n", myslice2) fmt.Printf("length = %d\n", len(myslice2)) fmt.Printf("capacity = %d\n", cap(myslice2)) }
myslice1 = [0 0 0 0 0] length = 5 capacity = 10 myslice2 = [0 0 0 0 0] length = 5 capacity = 5