Run ❯
Get your
own
website
×
Change Orientation
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